Skip to content

Commit

Permalink
chore(misc): updated verdaccio config files and local registry scripts (
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 authored May 18, 2021
1 parent fe0dec1 commit cbfbcd3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .verdaccio/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ packages:

# log settings
logs:
- { type: stdout, format: pretty, level: http }
type: stdout
format: pretty
level: http
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"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-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",
"format": "nx format",
"nx-release": "./scripts/nx-release.js",
Expand Down
21 changes: 12 additions & 9 deletions scripts/e2e-build-package-publish.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { execSync } from 'child_process';
import { readFileSync, removeSync, writeFileSync } from 'fs-extra';
import { readdirSync } from 'fs';
import { removeSync } from 'fs-extra';
import { readFileSync, writeFileSync, readdirSync } from 'fs';
import {
prettierVersion,
typescriptVersion,
} from '../packages/workspace/src/utils/versions';

process.env.PUBLISHED_VERSION = `9999.0.2`;
process.env.npm_config_registry = `http://localhost:4872`;
Expand All @@ -12,7 +16,7 @@ export function buildPackagePublishAndCleanPorts() {
removeSync('./tmp/angular/proj-backup');
removeSync('./tmp/local-registry');

build(process.env.PUBLISHED_VERSION, '3.9.3', '2.1.2');
build(process.env.PUBLISHED_VERSION);
try {
updateVersionsAndPublishPackages();
} catch (e) {
Expand All @@ -21,7 +25,7 @@ export function buildPackagePublishAndCleanPorts() {
}
}

export const getDirectories = (source) =>
export const getDirectories = (source: string) =>
readdirSync(source, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
Expand All @@ -38,13 +42,13 @@ function updateVersionsAndPublishPackages() {
});
}

function updateVersion(packagePath) {
function updateVersion(packagePath: string) {
return execSync(`npm version ${process.env.PUBLISHED_VERSION}`, {
cwd: packagePath,
});
}

function publishPackage(packagePath, npmMajorVersion: number) {
function publishPackage(packagePath: string, npmMajorVersion: number) {
if (process.env.npm_config_registry.indexOf('http://localhost') === -1) {
throw Error(`
------------------
Expand Down Expand Up @@ -79,7 +83,7 @@ function publishPackage(packagePath, npmMajorVersion: number) {
}
}

function build(nxVersion, typescriptVersion, prettierVersion) {
function build(nxVersion: string) {
try {
execSync('npx nx run-many --target=build --all', {
stdio: ['ignore', 'ignore', 'ignore'],
Expand Down Expand Up @@ -133,8 +137,7 @@ function build(nxVersion, typescriptVersion, prettierVersion) {
].map((f) => `${BUILD_DIR}/${f}`);

files.forEach((f) => {
let content = readFileSync(f).toString();
content = content
const content = readFileSync(f, 'utf-8')
.replace(
/exports.nxVersion = '\*'/g,
`exports.nxVersion = '${nxVersion}'`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { exec } from 'child_process';
const { exec } = require('child_process');

const verdacio = exec(
`yarn verdaccio --config ./scripts/local-registry/config.yml --listen 4872`
'yarn verdaccio --config ./scripts/local-registry/config.yml'
);
verdacio.unref();

Expand All @@ -16,10 +16,6 @@ function outputHandling(data) {

verdacio.stdout.on('data', outputHandling);
verdacio.stderr.on('data', outputHandling);
verdacio.on('exit', (code) => {
process.exit(code);
});
verdacio.on('exit', (code) => process.exit(code));

setTimeout(() => {
process.exit(0);
}, 2000);
setTimeout(() => process.exit(0), 2000);
14 changes: 7 additions & 7 deletions scripts/local-registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ fi
if [[ $COMMAND == "disable" ]]; then
npm config delete registry
yarn config delete registry
CURRENT_NPM_REGISTRY=`npm config get registry`
CURRENT_YARN_REGISTRY=`yarn config get registry`
CURRENT_NPM_REGISTRY=$(npm config get registry)
CURRENT_YARN_REGISTRY=$(yarn config get registry)

echo "Reverting registries"
echo " > NPM: $CURRENT_NPM_REGISTRY"
echo " > YARN: $CURRENT_YARN_REIGSTRY"
fi

if [[ $COMMAND == "clear" ]]; then
echo "Clearing Local Registry"
rm -rf ./build/local-registry/storage
echo "Clearing Local Registry"
rm -rf ./build/local-registry/storage
fi

if [[ $COMMAND == "start" ]]; then
echo "Starting Local Registry"
VERDACCIO_HANDLE_KILL_SIGNALS=true
npx verdaccio --config ./.verdaccio/config.yml
echo "Starting Local Registry"
VERDACCIO_HANDLE_KILL_SIGNALS=true
yarn verdaccio --config ./.verdaccio/config.yml
fi
6 changes: 5 additions & 1 deletion scripts/local-registry/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# path to a directory with all packages
storage: ../../tmp/local-registry/storage

listen: localhost:4872

# a list of other known repositories we can talk to
uplinks:
npmjs:
Expand All @@ -24,4 +26,6 @@ packages:

# log settings
logs:
- { type: stdout, format: pretty, level: warn }
type: stdout
format: pretty
level: warn

0 comments on commit cbfbcd3

Please sign in to comment.