How to publish alpha npm module without confusing the community? - npm

Given an useless pet node module.
./node_modules/salutations.js :
var cl = function (msg) { console.log(msg) }
var hi = function () { cl("Hi !") }
var seeYa = function () { cl("SeeYa !") }
exports.hi = hi;
exports.seeYa = seeYa;
./script.js :
var salutations = require('salutations')
salutations.hi(); // returns: "Hi !"
salutations.seeYa(); // returns: "SeeYa !"
./package.json
{
"name": "NodeSalutations",
"version": "0.0.1",
dependencies: {}
}
Given its creation sole purpose was to learn about the creation , then publication on npm.org of a minimalist node module.
Given there is nothing valuable on this module, so I don't want to set up a private account.
Is there a way to publish, test, then remove discretely the module on npm, without polluting npm.org ?
Edit : I did read npmjs.com's publish, unpublish, registry and scope.

You could just upload it to NPM.org and then deal with clean up later, Considering the scope of the module I'm sure no one would get invested enough to mind a removal/change.
Your other option is to host your own NPM repository for testing (this is what I would do) using something like sinopia

Related

Since ripple-lib-java is unmaintained, how do you manually sign a transaction?

Looking for a lightweight way to manually sign an OfferCreate ... it would be clumsy to start some JavaScript engine in order to get it done.
Hmm ... even though it hasn't been maintained for 4 years it looks like it still works.
Clone ripple-lib-java and do mvn install in ripple-bouncycastle & ripple-core
Then copy the built JARs into <YourProject>/libs
Add local dependencies in Gradle Kotlin DSL:
repositories {
flatDir {
dirs("libs")
}
}
dependencies {
implementation(":ripple-bouncycastle-0.0.1-SNAPSHOT")
implementation(":ripple-core-0.0.1-SNAPSHOT")
runtime("org.json:json:20190722") // No newskool kotlinx-serialization here :(
}
Create & sign OfferCreate:
val offerCreate = OfferCreate()
offerCreate.account(AccountID.fromString("r3jpWpUysF4SAkUNbG4WhDZ5mAJ7rGUDx6"))
offerCreate.expiration(UInt32(get2MinExpiration()))
offerCreate.fee(Amount(BigDecimal("0.00001")))
offerCreate.flags(UInt32(0))
offerCreate.sequence(UInt32(1))
val amountXRP = BigDecimal(200)
val amountBTC = convert(amountXRP, RIPPLE_XRP, BITCOIN)
offerCreate.takerGets(Amount(amountXRP))
offerCreate.takerPays(Amount(amountBTC, Currency.fromString(BITCOIN), AccountID.fromString(BITCOIN_TRUSTED_ISSUER)))
val signedTransaction = offerCreate.sign("[***Secret***]")
println(offerCreate.toJSON())
println(signedTransaction.tx_blob)
A bit annoying that you can't do a toJSON() on a SignedTransaction. It can
t be a security thing, since sign() only adds public key fields: https://xrpl.org/transaction-common-fields.html#signers-field

Teamcity Kotlin Build Base Class Property Extension

I've extracted my Teamcity builds as Kotlin outputs. I want to create a base class that defines a number of common steps/settings, but allow individual builds to extend these properties.
e.g.
open class BuildBase(init: BuildBase.() -> Unit) : BuildType({
steps {
powerShell {
name = "Write First Message"
id = "RUNNER_FirstMessage"
scriptMode = script {
content = """
Write-Host "First Message"
""".trimIndent()
}
}
}
})
object Mybuild : BuildBase({
steps { // This would add a new step to the list, without wiping out the original step
powerShell {
name = "Write Last Message"
id = "RUNNER_LastMessage"
scriptMode = script {
content = """
Write-Host "Last Message"
""".trimIndent()
}
}
}
})
In this example, I want to inherit the step from the base class, but add additional steps relevant to the specific build. Additionally, I'd want to inherit the base disableSettings (if any) and disable other steps.
Is this even possible? if so, how would I go about structuring the classes to enable it?
You might have found a solution already but here's how I would solve your problem.
Like in the GUI, TeamCity supports build templates.
In your case you would have a template like following:
object MyBuildTemplate: Template({
id("MyBuildTemplate")
name = "My build template"
steps {
powerShell {
name = "Write First Message"
id = "RUNNER_FirstMessage"
scriptMode = script {
content = """
Write-Host "First Message"
""".trimIndent()
}
}
}
})
Then, you can define a build config extending this template:
object MyBuildConfig: BuildType({
id("MyBuildConfig")
name = "My build config"
steps { // This would add a new step to the list, without wiping out the original step
powerShell {
name = "Write Last Message"
id = "RUNNER_LastMessage"
scriptMode = script {
content = """
Write-Host "Last Message"
""".trimIndent()
}
}
// afaik TeamCity would append the build config's steps to the template's steps but there is way to explicitly define the order of the steps:
stepsOrder = arrayListOf("RUNNER_FirstMessage", "RUNNER_LastMessage")
}
})
This way, you should also be able to inherit disableSettings from the template.

rollup equivalent of "browserify -r"

I need to force some modules into my bundle, as they are required dynamically through some code like below:
var moduleName = "someModule";
var myModule = require(moduleName);
I was using browserify to bundle this (through browserify -r or the API equivalent).
I am trying to switch to rollup and I don't figure out how to do this with rollup. Basically, I just want to force some modules into the bundle, and make them available globally through the require statement.
I think the key here is to use the new ES6 module syntax as described in the Rollup documentation. This will also give Rollup the possibility to apply features like chunking and tree-shaking.
Another important thing is to make it explicit what might get imported. By that I mean to use statements like 'import('./module1.js')' instead of 'import(some_variable)'. It is hard for Rollup to figure out all possible contents of the variable which gets used in the import. Therefore I would use explicit file names here but wrap everything in some kind of if/else condition.
Consider the following example:
File ./src/main.js:
let num = Math.random() * 10;
let condition = Math.round(num % 3);
let mod;
if (condition === 1) {
import('./module1.js').then((module)=> {
log(module);
});
} else if (condition === 2) {
import('./module2.js').then((module)=> {
log(module);
});
} else {
import('./module3.js').then((module)=> {
log(module);
});
}
function log(module) {
mod = module;
console.log(mod.test());
console.log('Done');
}
File ./src/module1.js:
function test() {
return 'This is 1!';
}
export { test };
The files module2.js and module3.js are the same like module1. The only difference is that they log 'This is 2!' and 'This is 3!'.
The Rollup config looks like this:
const production = !process.env.ROLLUP_WATCH;
export default {
inlineDynamicImports: true,
input: 'src/main.js',
output: {
dir: 'public/',
format: 'esm',
sourcemap: true
}
};
If you run 'rollup -c' then there will be one file './public/main.js'. This bundle will include all three modules. Usually Rollup would create main.js and three chunks. By using the setting 'inlineDynamicImports=true', Rollup puts everything in one file.
You can also change the format in the Rollup config to 'iife' (or amd, cjs, umd) if you want to.

What is a replacement for meta runners in TeamCity Kotlin DSL?

Apparently there's no support for metarunners generation in TeamCity Kotlin DSL. The files remain in plain XML.
How do I replace it using available DSL features? Say I'd like to do this:
steps {
step {
type = "mymetarunner" // compound meta-runner step
}
}
How do I define mymetarunner using Kotlin?
At the moment (TeamCity 2017.2), there is no way to define metarunners using Kotlin DSL.
Update
If having a real metarunner is not required, the solution is a small exercise in Kotlin DSL
Define a container class for settings you need for "metarunner"
class MyConfigClass {
var name = "Default Name"
var goals = "build"
var tasks = "build test"
var someUnusedProperty = 0
}
Define an extension function for steps block
fun BuildSteps.myMetaRunner(config: MyConfigClass.() -> Unit) {
val actualConfig = MyConfigClass() // new config instance
actualConfig.config() // apply closure to fill the config
// use the config to create actual steps
maven {
name = actualConfig.name
goals = actualConfig.goals
}
ant {
name = actualConfig.tasks
}
}
Use the extension function wherever you need
object A_Build : BuildType({
uuid = ...
steps {
myMetaRunner {
name = "This name will be used by maven step"
goals = "build whatever_goal"
tasks = "more ant tasks"
}
}
})
Bingo!

Referencing to values in typesafe config

I have a config file:
app {
system {
action-type = "REST"
}
}
roles = [${app.system.action-type} "notifier"]
I want roles to have a value [ RESTnotifier ], but this approach gives me an exception. Any suggestions?
com.typesafe.config.ConfigException$NotResolved: need to Config#resolve() each config before using it, see the API docs for Config#resolve()
You need to explicitly call resolve on the Config instance if you are going to be using replacements in the config. A quick example showing this:
import com.typesafe.config.ConfigFactory
import collection.JavaConversions._
object ConfigExample extends App{
val cfgString = """
app {
system {
action-type = "REST"
}
}
roles = [${app.system.action-type}"notifier"]
"""
val cfg = ConfigFactory.parseString(cfgString).resolve()
println(cfg.getStringList("roles").toList)
}
Note the explicit call to resolve. That should fix your issue.