chore(misc): updated verdaccio config files and local registry scripts (#5703)

This commit is contained in:
Phillip Barta 2021-05-18 17:27:48 +02:00 committed by GitHub
parent fe0dec1f99
commit cbfbcd3755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 27 deletions

View File

@ -36,4 +36,6 @@ packages:
# log settings # log settings
logs: logs:
- { type: stdout, format: pretty, level: http } type: stdout
format: pretty
level: http

View File

@ -13,7 +13,7 @@
"check-internal-links": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts", "check-internal-links": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/internal-link-checker.ts",
"check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts", "check-versions": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/check-versions.ts",
"check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts", "check-documentation-map": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/documentation/map-link-checker.ts",
"e2e-start-local-registry": "ts-node -P ./scripts/tsconfig.e2e.json scripts/e2e-start-local-registry.ts", "e2e-start-local-registry": "node ./scripts/e2e-start-local-registry.js",
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json scripts/e2e-build-package-publish.ts", "e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json scripts/e2e-build-package-publish.ts",
"format": "nx format", "format": "nx format",
"nx-release": "./scripts/nx-release.js", "nx-release": "./scripts/nx-release.js",

View File

@ -1,6 +1,10 @@
import { execSync } from 'child_process'; import { execSync } from 'child_process';
import { readFileSync, removeSync, writeFileSync } from 'fs-extra'; import { removeSync } from 'fs-extra';
import { readdirSync } from 'fs'; import { readFileSync, writeFileSync, readdirSync } from 'fs';
import {
prettierVersion,
typescriptVersion,
} from '../packages/workspace/src/utils/versions';
process.env.PUBLISHED_VERSION = `9999.0.2`; process.env.PUBLISHED_VERSION = `9999.0.2`;
process.env.npm_config_registry = `http://localhost:4872`; process.env.npm_config_registry = `http://localhost:4872`;
@ -12,7 +16,7 @@ export function buildPackagePublishAndCleanPorts() {
removeSync('./tmp/angular/proj-backup'); removeSync('./tmp/angular/proj-backup');
removeSync('./tmp/local-registry'); removeSync('./tmp/local-registry');
build(process.env.PUBLISHED_VERSION, '3.9.3', '2.1.2'); build(process.env.PUBLISHED_VERSION);
try { try {
updateVersionsAndPublishPackages(); updateVersionsAndPublishPackages();
} catch (e) { } catch (e) {
@ -21,7 +25,7 @@ export function buildPackagePublishAndCleanPorts() {
} }
} }
export const getDirectories = (source) => export const getDirectories = (source: string) =>
readdirSync(source, { withFileTypes: true }) readdirSync(source, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory()) .filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name); .map((dirent) => dirent.name);
@ -38,13 +42,13 @@ function updateVersionsAndPublishPackages() {
}); });
} }
function updateVersion(packagePath) { function updateVersion(packagePath: string) {
return execSync(`npm version ${process.env.PUBLISHED_VERSION}`, { return execSync(`npm version ${process.env.PUBLISHED_VERSION}`, {
cwd: packagePath, cwd: packagePath,
}); });
} }
function publishPackage(packagePath, npmMajorVersion: number) { function publishPackage(packagePath: string, npmMajorVersion: number) {
if (process.env.npm_config_registry.indexOf('http://localhost') === -1) { if (process.env.npm_config_registry.indexOf('http://localhost') === -1) {
throw Error(` throw Error(`
------------------ ------------------
@ -79,7 +83,7 @@ function publishPackage(packagePath, npmMajorVersion: number) {
} }
} }
function build(nxVersion, typescriptVersion, prettierVersion) { function build(nxVersion: string) {
try { try {
execSync('npx nx run-many --target=build --all', { execSync('npx nx run-many --target=build --all', {
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
@ -133,8 +137,7 @@ function build(nxVersion, typescriptVersion, prettierVersion) {
].map((f) => `${BUILD_DIR}/${f}`); ].map((f) => `${BUILD_DIR}/${f}`);
files.forEach((f) => { files.forEach((f) => {
let content = readFileSync(f).toString(); const content = readFileSync(f, 'utf-8')
content = content
.replace( .replace(
/exports.nxVersion = '\*'/g, /exports.nxVersion = '\*'/g,
`exports.nxVersion = '${nxVersion}'` `exports.nxVersion = '${nxVersion}'`

View File

@ -1,7 +1,7 @@
import { exec } from 'child_process'; const { exec } = require('child_process');
const verdacio = exec( const verdacio = exec(
`yarn verdaccio --config ./scripts/local-registry/config.yml --listen 4872` 'yarn verdaccio --config ./scripts/local-registry/config.yml'
); );
verdacio.unref(); verdacio.unref();
@ -16,10 +16,6 @@ function outputHandling(data) {
verdacio.stdout.on('data', outputHandling); verdacio.stdout.on('data', outputHandling);
verdacio.stderr.on('data', outputHandling); verdacio.stderr.on('data', outputHandling);
verdacio.on('exit', (code) => { verdacio.on('exit', (code) => process.exit(code));
process.exit(code);
});
setTimeout(() => { setTimeout(() => process.exit(0), 2000);
process.exit(0);
}, 2000);

View File

@ -12,8 +12,8 @@ fi
if [[ $COMMAND == "disable" ]]; then if [[ $COMMAND == "disable" ]]; then
npm config delete registry npm config delete registry
yarn config delete registry yarn config delete registry
CURRENT_NPM_REGISTRY=`npm config get registry` CURRENT_NPM_REGISTRY=$(npm config get registry)
CURRENT_YARN_REGISTRY=`yarn config get registry` CURRENT_YARN_REGISTRY=$(yarn config get registry)
echo "Reverting registries" echo "Reverting registries"
echo " > NPM: $CURRENT_NPM_REGISTRY" echo " > NPM: $CURRENT_NPM_REGISTRY"
@ -28,5 +28,5 @@ fi
if [[ $COMMAND == "start" ]]; then if [[ $COMMAND == "start" ]]; then
echo "Starting Local Registry" echo "Starting Local Registry"
VERDACCIO_HANDLE_KILL_SIGNALS=true VERDACCIO_HANDLE_KILL_SIGNALS=true
npx verdaccio --config ./.verdaccio/config.yml yarn verdaccio --config ./.verdaccio/config.yml
fi fi

View File

@ -1,6 +1,8 @@
# path to a directory with all packages # path to a directory with all packages
storage: ../../tmp/local-registry/storage storage: ../../tmp/local-registry/storage
listen: localhost:4872
# a list of other known repositories we can talk to # a list of other known repositories we can talk to
uplinks: uplinks:
npmjs: npmjs:
@ -24,4 +26,6 @@ packages:
# log settings # log settings
logs: logs:
- { type: stdout, format: pretty, level: warn } type: stdout
format: pretty
level: warn