create-swdg-frontend 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-swdg-frontend",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Scaffold a new SWDG frontend project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,13 +10,9 @@ const swdgDir = path.join(rootDir, 'swdg');
10
10
  const createPkgPath = path.join(createDir, 'package.json');
11
11
  const swdgPkgPath = path.join(swdgDir, 'package.json');
12
12
 
13
- const args = process.argv.slice(2);
14
- const isDryRun = args.includes('--dry-run') || args.includes('--dry');
15
- const input = args.find((arg) => !arg.startsWith('-'));
13
+ const input = process.argv[2];
16
14
  if (!input) {
17
- console.error(
18
- 'Usage: node scripts/release.mjs <patch|minor|major|x.y.z> [--dry-run]',
19
- );
15
+ console.error('Usage: node scripts/release.mjs <x.y.z>');
20
16
  process.exit(1);
21
17
  }
22
18
 
@@ -25,23 +21,15 @@ const writeJson = (filePath, data) =>
25
21
  fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n', 'utf8');
26
22
 
27
23
  const isValidVersion = (value) => /^\d+\.\d+\.\d+$/.test(value);
28
- const bumpVersion = (current, kind) => {
29
- if (!isValidVersion(current)) {
30
- throw new Error(`Invalid current version: ${current}`);
31
- }
32
- const [major, minor, patch] = current.split('.').map(Number);
33
- if (kind === 'major') return `${major + 1}.0.0`;
34
- if (kind === 'minor') return `${major}.${minor + 1}.0`;
35
- if (kind === 'patch') return `${major}.${minor}.${patch + 1}`;
36
- throw new Error(`Invalid bump type: ${kind}`);
37
- };
38
-
39
24
  const createPkg = readJson(createPkgPath);
40
25
  const swdgPkg = readJson(swdgPkgPath);
41
26
 
42
- const nextVersion = isValidVersion(input)
43
- ? input
44
- : bumpVersion(createPkg.version, input);
27
+ if (!isValidVersion(input)) {
28
+ console.error('Version must be in x.y.z format, e.g. 0.1.2');
29
+ process.exit(1);
30
+ }
31
+
32
+ const nextVersion = input;
45
33
 
46
34
  createPkg.version = nextVersion;
47
35
  swdgPkg.version = nextVersion;
@@ -51,26 +39,21 @@ swdgPkg.dependencies['create-swdg-frontend'] = `^${nextVersion}`;
51
39
  writeJson(createPkgPath, createPkg);
52
40
  writeJson(swdgPkgPath, swdgPkg);
53
41
 
54
- if (isDryRun) {
42
+ try {
43
+ execSync('npm config set registry https://registry.npmjs.org/', {
44
+ stdio: 'inherit',
45
+ });
55
46
  execSync('pnpm -C create-swdg run prepublishOnly', { stdio: 'inherit' });
56
- console.log('[dry-run] Skip npm registry switch and publish.');
57
- } else {
58
- try {
59
- execSync('npm config set registry https://registry.npmjs.org/', {
60
- stdio: 'inherit',
61
- });
62
- execSync('pnpm -C create-swdg run prepublishOnly', { stdio: 'inherit' });
63
- execSync('npm publish --access public --registry https://registry.npmjs.org/', {
64
- stdio: 'inherit',
65
- cwd: createDir,
66
- });
67
- execSync('npm publish --access public --registry https://registry.npmjs.org/', {
68
- stdio: 'inherit',
69
- cwd: swdgDir,
70
- });
71
- } finally {
72
- execSync('npm config set registry https://registry.npmmirror.com/', {
73
- stdio: 'inherit',
74
- });
75
- }
47
+ execSync('npm publish --access public --registry https://registry.npmjs.org/', {
48
+ stdio: 'inherit',
49
+ cwd: createDir,
50
+ });
51
+ execSync('npm publish --access public --registry https://registry.npmjs.org/', {
52
+ stdio: 'inherit',
53
+ cwd: swdgDir,
54
+ });
55
+ } finally {
56
+ execSync('npm config set registry https://registry.npmmirror.com/', {
57
+ stdio: 'inherit',
58
+ });
76
59
  }