make lerna update package containing 2 versions - npm

I have a requirement where we will have the depedency declared in the package.json as
"sample-package" : "file:../../sample-package || 1.0.0"
when we publish "sample-package" we want to make sure it updates the package dependency as below:
"sample-package" : "3.0.0 || 1.0.0"
but looks like lerna is not updating the version and it is same as above after checking the dependency in published package.
how to achieve the above result?
our lerna.json looks like below:
{
"packages": [
"components/*"
],
"version": "3.0.0",
"command": {
"init": {
"exact": true
},
"version": {
"exact": true,
"forcePublish": true
}
}
}

Related

How to setup plain text env vars in Expo build?

I'm working on an expo project and trying to link environment variables for build profiles. I was trying to achieve that using eas.json but I cannot get it to work.
I have two build profiles - development and production:
{
"cli": {
"version": ">= 3.3.1"
},
"build": {
"development": {
"distribution": "internal",
"env": {
"API_URL": "https://staging-api.example.com",
"STRIPE_ENV": "test"
},
"ios": {
"resourceClass": "m1-medium"
}
},
"production": {
"env": {
"API_URL": "https://api.example.com",
"STRIPE_ENV": "production"
},
"ios": {
"resourceClass": "m1-medium"
},
"autoIncrement": true
}
},
"submit": {
"production": {
...
}
}
}
Build command:
eas build --profile development --platform ios
Based on their documentation, I sohuld be able to use process.env.API_URL but it's undefined.
Am I missing something?
Putting those values in eas.json is only ensuring that those envs will be set during the build process on EAS. To pass them to the application code you need to pass those values to the extra field in app.config.js.
process.env.API_URL will be defined when evaluating app.config.js, but in your application code, you need to access those values via expo-constants package.

How to use argument on package.json script from package.json attribute

Imagine I have the following package.json structure:
{
"version": "2.0.1",
"scripts": {
"testing": "build --version 2.0.1"
}
}
I know you could replace the actual version with environment variables but is it possible with a package.json attribute? For example:
{
"version": "2.0.1",
"scripts": {
"testing": "build --version ${package.version}"
}
}

Npm Publish Issue - Artifactory

I am publishing an npm library to an npm repo on artifactory. The library is built using angular and the dist folder and package.json looks correct. When publishing, the request it's self is published but not the actual artifact.
All i see on artifactory is a single file and not a folder containing my package
Running
npm publish
Package.json
{
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.0",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
}
}
What actually gets published to artifactory in a single file.
{
"_id": "#abce/embedded-auth",
"name": "#abce/embedded-auth",
"dist-tags": {
"latest": "1.0.0-dev.1"
},
"versions": {
"1.0.0-dev.1": {
"name": "#abce/embedded-auth",
"version": "1.0.0-dev.1",
"main": "bundles/abce-auth.umd.js",
"module": "fesm5/abce-auth.js",
"es2015": "fesm2015/abce-auth.js",
"esm5": "esm5/abce-auth.js",
"esm2015": "esm2015/abce-auth.js",
"fesm5": "fesm5/abce-auth.js",
"fesm2015": "fesm2015/abce-auth.js",
"typings": "abce-auth.d.ts",
"metadata": "abce-auth.metadata.json",
"sideEffects": false,
"dependencies": {
"tslib": "^1.9.0"
},
"readme": "ERROR: No README data found!",
"_id": "#abce/embedded-auth#1.0.0-dev.1",
"_npmVersion": "6.4.1",
"_nodeVersion": "10.15.3",
"_npmUser": {
"name": "deployment",
"email": "bob#bob.ie"
},
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"dist": {
"integrity": "sha512-rpTN1sMpwnMwehzWUqbV+zElzaOlF5ekQRCQMncy6c+i4TAp5jbBobvzrhgl0ORqHgJn3Eo+EcrRgYLSjV7MdQ==",
"shasum": "71f654dd5fddb20a9d5063171d5293424a4271c7",
"tarball": "http://abce.jfrog.io/abce/internal-npm-dev/#abce/embedded-auth/-/#abce/embedded-auth-1.0.0-dev.1.tgz"
}
}
},
"readme": "ERROR: No README data found!",
"maintainers": [
{
"name": "deployment",
"email": "bob#bob.ie"
}
],
"_attachments": {
"#abce/embedded-auth-1.0.0-dev.1.tgz": {
"content_type": "application/octet-stream",
"data": "correctly populated tarball base64 data here. I checked it and it is correct",
"length": 12092
}
}
}
Expect:
I would expect the package to be parsed from the request and the package published correctly
Actual:
The put request data from the npm publish command is published as a file
npm version: 6.9.0
node version: v12.3.1(has also been run with 10.15.3)
Any ideas?
Please check the registry URL that you are using from npm, if it doesn't include /api/npm - it is invalid.
Wrong URL: https://domain/artifactory/some-directory/.
Valid URL: https://domain/artifactory/api/npm/some-directory/.

npm run build for React app using incorrect path for index.js source

My npm run build fails with this:
✖ Building demo
Failed to compile with 1 error.
ERROR in multi ./node_modules/nwb/polyfills.js ./demo/src/index.js
Module not found: Error: Can't resolve '/Users/david/git/demoapp/demo/src/index.js' in '/Users/david/git/demoapp'
# multi ./node_modules/nwb/polyfills.js ./demo/src/index.js
Error running command: Build failed with errors.
Error: Build failed with errors.
at /Users/david/git/demoapp/node_modules/nwb/lib/webpackBuild.js:82:17
at emitRecords.err (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:368:12)
at next (/Users/david/git/demoapp/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/david/git/demoapp/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/Users/david/git/demoapp/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:365:9)
at require.forEach.err (/Users/david/git/demoapp/node_modules/webpack/lib/Compiler.js:354:15)
at /Users/david/git/demoapp/node_modules/async/dist/async.js:473:16
at iteratorCallback (/Users/david/git/demoapp/node_modules/async/dist/async.js:1050:13)
at /Users/david/git/demoapp/node_modules/async/dist/async.js:958:16
at /Users/david/git/demoapp/node_modules/graceful-fs/graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:112:15)`
This is incorrect in '/Users/david/git/demoapp' because the index is in /Users/david/git/demoapp/src or /Users/david/git/demoapp/lib for the ES5 version, /Users/david/git/demoapp/es for the ES6 version
My nwb.config.js looks like this:
const path = require('path');
function excludeNodeModulesExcept (modules) {
var pathSep = path.sep;
if (pathSep === '\\') { // must be quoted for use in a regexp:
pathSep = '\\\\';
}
var moduleRegExps = modules.map(function (modName) { return new RegExp("node_modules" + pathSep + modName);});
return function (modulePath) {
if (/node_modules/.test(modulePath)) {
for (var i = 0; i < moduleRegExps.length; i++) {
if (moduleRegExps[i].test(modulePath)) {
console.log("Allowed babel transpiling of " + modulePath);
return false;
}
}
return true;
}
return false;
};
}
module.exports = {
type: 'react-component',
npm: {
esModules: true,
umd: false
},
webpack: {
rules: {
babel: {
exclude: excludeNodeModulesExcept(['kontraktor-client', 'kontraktor-common']),
options: {
babelrc: false,
cacheDirectory: true
}
}
}
}
};
The relevant part of my package.json looks like this:
{
"name": "demoapp",
"version": "1.0.0",
"description": "Demo App",
"main": "lib/index.js",
"module": "es/index.js",
"files": [
"css",
"es",
"lib",
"umd"
],
"scripts": {
"build": "nwb build-react-component",
"images": "node imagesServer/index.js",
"serve": "nwb serve-react-app",
"clean": "nwb clean-module",
"start": "npm-run-all --parallel serve images",
"test": "nwb test-react",
"test:coverage": "nwb test-react --coverage",
"test:watch": "nwb test-react --server"
},
Is there a way of specify to nwb where the source index.js is located? I want to build a ES5 version of this React application.
Another confusion is that some posts and tutorials states that a directory named 'dist' is used to output the built code from 'npm run build'?
react-app doesnot support importing files outside src folder. so short answer ;you will have to eject'
or you can use npm link but your module must be exporting es5 beacuse again react-app will not transpile it for you.

Package.json, add local directory to node-modules

I have local library for some graphs and I need add it to node_modules. Is there any way how to add this library using package.json?
Our package.json looks like:
{
"name": "name",
"version": "1.01.01",
"scripts": {
...
},
"dependencies": {
...
},
...
}
I mean to add something like:
"directory": {
"my-library": "./src/path/to/my/lib"
}
Thank for any help.
According to the documentation you can define your local directories as dependencies in the following format:
{
"name": "baz",
"dependencies": {
"bar": "file:../foo/bar"
}
}
You can read more here: https://docs.npmjs.com/files/package.json#local-paths