Skip to content

Commit 5ff3de1

Browse files
committed
fix(tools): Fix publish local
1 parent 262ae9e commit 5ff3de1

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

tools/scripts/publish-local.ts renamed to tools/scripts/publish-local.mjs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
2-
import { releasePublish, releaseVersion } from 'nx/release';
1+
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry.js';
2+
import { releasePublish, releaseVersion } from 'nx/release/index.js';
33
import { execSync } from 'node:child_process';
4-
import { rmSync } from 'node:fs';
4+
import { mkdirSync } from 'node:fs';
55
import { join } from 'node:path';
6+
import { exists } from '@nx/plugin/testing.js';
67

78
// Related to the target generated in the root project.json
89
const localRegistryTarget = '@huge-nx/source:local-registry';
910

11+
const devTmpRepository = join(process.cwd(), 'tmp', 'huge-nx-dev');
12+
13+
if (!exists(devTmpRepository)) {
14+
mkdirSync(devTmpRepository, { recursive: true });
15+
}
16+
1017
// Callback used to stop Verdaccio process
1118
// eslint-disable-next-line @typescript-eslint/no-empty-function
1219
let stopLocalRegistry = () => {};
1320

14-
const hugeNxConventionsArgv = process.argv[2];
15-
const nxVersion = process.argv[3] ?? 'latest';
16-
const workspaceName = hugeNxConventionsArgv.split('/')?.pop()?.replace('.conventions.ts', `-${nxVersion}`);
17-
if (!hugeNxConventionsArgv || !workspaceName) {
18-
throw new Error('Provide the conventions name like npx ts-node ./tools/scripts/publish-local.ts huge-angular-monorep');
19-
}
20-
2121
(async () => {
2222
try {
2323
execSync('pkill -f verdaccio', { stdio: 'inherit' });
@@ -46,15 +46,9 @@ if (!hugeNxConventionsArgv || !workspaceName) {
4646
firstRelease: true,
4747
});
4848

49-
rmSync(workspaceName, { force: true, recursive: true });
50-
51-
const createCmd = `npx --yes create-huge-nx@latest ${workspaceName} --hugeNxConventions=${hugeNxConventionsArgv} --nxVersion ${nxVersion} --nxCloud skip --interactive false --verbose`;
52-
53-
console.log(createCmd);
54-
55-
execSync(createCmd, {
49+
execSync(`npx create-huge-nx@latest`, {
5650
stdio: 'inherit',
57-
cwd: join(process.cwd(), '..'),
51+
cwd: devTmpRepository,
5852
env: {
5953
...process.env,
6054
npm_config_registry: 'http://localhost:4873',
@@ -63,7 +57,7 @@ if (!hugeNxConventionsArgv || !workspaceName) {
6357
},
6458
});
6559

66-
stopLocalRegistry();
60+
// stopLocalRegistry();
6761

6862
const exitStatus = Object.values(publishStatus).reduce((acc, result) => result.code + acc, 0);
6963
process.exit(exitStatus);

0 commit comments

Comments
 (0)