chore(repo): fix npm@7 publish for e2e
This commit is contained in:
parent
5f222245ed
commit
3de68dc529
2
.github/workflows/e2e-matrix.yml
vendored
2
.github/workflows/e2e-matrix.yml
vendored
@ -37,7 +37,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
node-version: ${{ matrix.node_version }}
|
||||
- run: yarn install
|
||||
|
||||
- name: Install PNPM
|
||||
|
||||
@ -6,7 +6,6 @@ import {
|
||||
uniq,
|
||||
updateFile,
|
||||
workspaceConfigName,
|
||||
getPackageManagerCommand,
|
||||
} from '@nrwl/e2e/utils';
|
||||
|
||||
describe('Run Commands', () => {
|
||||
@ -26,17 +25,21 @@ describe('Run Commands', () => {
|
||||
'SHARED_VAR=shared-nested-value\nNESTED_ONLY=nested-only-value'
|
||||
);
|
||||
|
||||
const command =
|
||||
process.platform === 'win32'
|
||||
? `"echo %SHARED_VAR% %ROOT_ONLY% %NESTED_ONLY%"` // Windows
|
||||
: getPackageManagerCommand().runNx.startsWith('yarn')
|
||||
? `'echo $SHARED_VAR $ROOT_ONLY $NESTED_ONLY'` // Yarn
|
||||
: `'echo "\\$SHARED_VAR" "\\$ROOT_ONLY" "\\$NESTED_ONLY"'`; // NPM, PNPM
|
||||
const envFile = `apps/${nodeapp}/.custom.env`;
|
||||
runCLI(
|
||||
`generate @nrwl/workspace:run-commands echoEnvVariables --command=${command} --envFile=${envFile} --project=${nodeapp}`
|
||||
`generate @nrwl/workspace:run-commands echoEnvVariables --command=echo --envFile=${envFile} --project=${nodeapp}`
|
||||
);
|
||||
|
||||
const command =
|
||||
process.platform === 'win32'
|
||||
? `%SHARED_VAR% %ROOT_ONLY% %NESTED_ONLY%` // Windows
|
||||
: `$SHARED_VAR $ROOT_ONLY $NESTED_ONLY`;
|
||||
const config = readJson(workspaceConfigName());
|
||||
config.projects[
|
||||
nodeapp
|
||||
].targets.echoEnvVariables.options.command += ` ${command}`;
|
||||
updateFile(workspaceConfigName(), JSON.stringify(config, null, 2));
|
||||
|
||||
const result = runCLI('echoEnvVariables');
|
||||
expect(result).toContain('shared-root-value');
|
||||
expect(result).not.toContain('shared-nested-value');
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
"eslint-plugin-import": "^2.20.1",
|
||||
"eslint-plugin-jsx-a11y": "^6.2.3",
|
||||
"eslint-plugin-react": "^7.18.3",
|
||||
"eslint-plugin-react-hooks": "^2.4.0",
|
||||
"eslint-plugin-react-hooks": "4.2.0",
|
||||
"url-loader": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { readdirSync } from 'fs';
|
||||
import { ensureDirSync, removeSync } from 'fs-extra';
|
||||
import { ensureDirSync, removeSync, writeFileSync } from 'fs-extra';
|
||||
const kill = require('tree-kill');
|
||||
import { build } from './package';
|
||||
|
||||
process.env.PUBLISHED_VERSION = `9999.0.2`;
|
||||
process.env.npm_config_registry = `http://localhost:4872/`;
|
||||
process.env.npm_config_registry = `http://localhost:4872`;
|
||||
process.env.YARN_REGISTRY = process.env.npm_config_registry;
|
||||
|
||||
export const getDirectories = (source) =>
|
||||
@ -19,7 +19,7 @@ function updateVersion(packagePath) {
|
||||
});
|
||||
}
|
||||
|
||||
function publishPackage(packagePath) {
|
||||
function publishPackage(packagePath, npmMajorVersion: number) {
|
||||
if (process.env.npm_config_registry.indexOf('http://localhost') === -1) {
|
||||
throw Error(`
|
||||
------------------
|
||||
@ -29,6 +29,21 @@ function publishPackage(packagePath) {
|
||||
}
|
||||
try {
|
||||
console.log(` 📦 ${packagePath}`);
|
||||
|
||||
// NPM@7 requires a token to publish, thus, is just a matter of fake a token to bypass npm.
|
||||
// See: https://twitter.com/verdaccio_npm/status/1357798427283910660
|
||||
if (npmMajorVersion === 7) {
|
||||
writeFileSync(
|
||||
`${packagePath}/.npmrc`,
|
||||
`registry=${
|
||||
process.env.npm_config_registry
|
||||
}\n${process.env.npm_config_registry.replace(
|
||||
'http:',
|
||||
''
|
||||
)}/:_authToken=fake`
|
||||
);
|
||||
}
|
||||
|
||||
execSync(`npm publish`, {
|
||||
cwd: packagePath,
|
||||
env: process.env,
|
||||
@ -40,9 +55,14 @@ function publishPackage(packagePath) {
|
||||
}
|
||||
|
||||
export function setup() {
|
||||
const npmMajorVersion = execSync(`npm --version`)
|
||||
.toString('utf-8')
|
||||
.trim()
|
||||
.split('.')[0];
|
||||
|
||||
getDirectories('./build/packages').map((pkg) => {
|
||||
updateVersion(`./build/packages/${pkg}`);
|
||||
publishPackage(`./build/packages/${pkg}`);
|
||||
publishPackage(`./build/packages/${pkg}`, +npmMajorVersion);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
# path to a directory with all packages
|
||||
storage: ../../tmp/local-registry/storage
|
||||
auth:
|
||||
htpasswd:
|
||||
file: ./htpasswd
|
||||
max_users: 1
|
||||
|
||||
# a list of other known repositories we can talk to
|
||||
uplinks:
|
||||
|
||||
@ -1 +0,0 @@
|
||||
test:$6FrCaT/v0dwE:autocreated 2020-03-25T19:10:50.254Z
|
||||
Loading…
x
Reference in New Issue
Block a user