Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into bugfix/CXSPA-1128
Browse files Browse the repository at this point in the history
  • Loading branch information
Pio-Bar committed Oct 10, 2024
2 parents 0d87475 + e09d954 commit 938dba3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tools/schematics/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,21 @@ const commands = [
'test all schematics',
'exit',
] as const;
type Command = typeof commands[number];
type Command = (typeof commands)[number];

const buildLibRegEx = new RegExp('build (.*?)/schematics');
const verdaccioUrl = 'http://localhost:4873/';
const npmUrl = 'https://registry.npmjs.org/';
const verdaccioRegistryUrl = 'http://localhost:4873/';
const originalRegistryUrl = execSync('npm config get @spartacus:registry')
.toString()
.trim();

function startVerdaccio(): ChildProcess {
execSync('rm -rf ./scripts/install/storage');

console.log('Waiting for verdaccio to boot...');
const res = exec('verdaccio --config ./scripts/install/config.yaml');
try {
execSync(`npx wait-on ${verdaccioUrl} --timeout 10000`);
execSync(`npx wait-on ${verdaccioRegistryUrl} --timeout 10000`);
} catch (_e) {
console.log(
chalk.red(
Expand All @@ -102,13 +104,13 @@ function startVerdaccio(): ChildProcess {
process.exit(1);
}
console.log('Pointing npm to verdaccio');
execSync(`npm config set @spartacus:registry ${verdaccioUrl}`);
execSync(`npm config set @spartacus:registry ${verdaccioRegistryUrl}`);
return res;
}

function beforeExit(): void {
console.log('Setting npm back to npmjs.org');
execSync(`npm config set @spartacus:registry ${npmUrl}`);
execSync(`npm config set @spartacus:registry ${originalRegistryUrl}`);
if (verdaccioProcess) {
try {
console.log('Killing verdaccio');
Expand Down Expand Up @@ -140,7 +142,7 @@ function publishLibs(): void {
const dir = path.dirname(packagePath);
console.log(`\nPublishing ${content.name}`);
execSync(
`cd ${dir} && npm publish --registry=${verdaccioUrl} --no-git-tag-version`,
`cd ${dir} && npm publish --registry=${verdaccioRegistryUrl} --no-git-tag-version`,
{ stdio: 'inherit' }
);
});
Expand Down

0 comments on commit 938dba3

Please sign in to comment.