Skip to content

Commit b6b06ab

Browse files
committed
update versioning
1 parent bc34b80 commit b6b06ab

File tree

3 files changed

+5
-41
lines changed

3 files changed

+5
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"clean": "rimraf dist **/*/.testInput **/*/.testOutput .assetpack packages/assetpack/test/cache/**/*",
1313
"lint:fix": "eslint . --fix",
1414
"prepare": "husky",
15-
"version:main": "node scripts/version.mjs",
15+
"version:main": "npm run version:main --workspace @assetpack/core",
1616
"version:branch": "VERSION=$VERSION npm run version:branch --workspace @assetpack/core",
1717
"release": "npm run release --workspace @assetpack/core",
1818
"release:branch": "PUBLISH_TAG=$PUBLISH_TAG npm run release:branch --workspace @assetpack/core",

packages/assetpack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"release": "node ../../scripts/publish.mjs",
3939
"release:branch": "node ../../scripts/publish-branch.mjs",
4040
"version:branch": "node ../../scripts/version-branch.mjs",
41+
"version:main": "node ../../scripts/version.mjs",
4142
"watch": "tsc -w"
4243
},
4344
"husky": {

scripts/version.mjs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
import { readFile, writeFile } from 'fs/promises';
2+
import { readFile } from 'fs/promises';
33
import { join } from 'path';
44
import { bump } from './bump.mjs';
55
import { spawn } from './spawn.mjs';
@@ -21,34 +21,6 @@ const readJsonFile = async (filePath) => {
2121
}
2222
};
2323

24-
/**
25-
* Write a JSON object to a file
26-
* @param {string} filePath - Path to write the file
27-
* @param {Object} data - Data to write
28-
*/
29-
const writeJsonFile = async (filePath, data) => {
30-
try {
31-
const content = `${JSON.stringify(data, null, 2)}\n`;
32-
33-
await writeFile(filePath, content, 'utf8');
34-
} catch (error) {
35-
throw new Error(`Failed to write JSON file ${filePath}: ${error.message}`);
36-
}
37-
};
38-
39-
/**
40-
* Update package.json version
41-
* @param {string} packagePath - Path to package.json
42-
* @param {string} newVersion - New version to set
43-
*/
44-
const updatePackageVersion = async (packagePath, newVersion) => {
45-
const packageJson = await readJsonFile(packagePath);
46-
47-
packageJson.version = newVersion;
48-
await writeJsonFile(packagePath, packageJson);
49-
console.log(`Updated ${packagePath} to version ${newVersion}`);
50-
};
51-
5224
/**
5325
* Bump the version of the package and update all relevant package.json files
5426
* @returns {Promise<string>} The next version
@@ -70,17 +42,8 @@ const version = async () => {
7042
// Update root package.json using npm version command
7143
console.log('Updating root package.json...');
7244
await spawn('npm', ['version', nextVersion]);
73-
74-
// Update assetpack package.json
75-
const assetpackPackagePath = join(rootDir, 'packages', 'assetpack', 'package.json');
76-
77-
console.log('Updating assetpack package.json...');
78-
await updatePackageVersion(assetpackPackagePath, nextVersion);
79-
await spawn('git', ['add', assetpackPackagePath]);
80-
await spawn('git', ['commit', '-m', `chore: bump version to ${nextVersion}`]);
81-
// push changes to git
82-
await spawn('git', ['push']);
83-
await spawn('git', ['push', '--tags']);
45+
// push commit and its tag
46+
await spawn('git', ['push', '--follow-tags']);
8447

8548
console.log(`✅ Version bump completed: ${currentVersion}${nextVersion}`);
8649
} catch (error) {

0 commit comments

Comments
 (0)