Skip to content

Commit 3210cad

Browse files
authored
release plan : increment version from 0.0.0 (#831)
* release plan : increment version from 0.0.0 * update new-plugin
1 parent 6ed0767 commit 3210cad

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.github/bin/new-plugin.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ console.log(`- Creating new plugin ${pluginName}`);
6060
path.join(pluginDir, 'CHANGELOG.md'),
6161
`# Changes to PostCSS ${pluginName}
6262
63-
### 1.0.0 (Unreleased)
63+
### Unreleased (major)
6464
6565
- Initial version
6666
`,
@@ -74,7 +74,7 @@ console.log(`- Creating new plugin ${pluginName}`);
7474
const packageInfo = JSON.parse(await fsp.readFile(path.join(pluginDir, 'package.json'), 'utf8'));
7575
packageInfo.name = packageName;
7676
packageInfo.description = `TODO: Add description for ${pluginName}`;
77-
packageInfo.version = '1.0.0';
77+
packageInfo.version = '0.0.0';
7878
packageInfo.homepage = `https://github.com/csstools/postcss-plugins/tree/main/plugins/${pluginSlug}#readme`;
7979
packageInfo.bugs = 'https://github.com/csstools/postcss-plugins/issues';
8080
packageInfo.csstools.exportName = exportName;

.github/bin/release-plan/npm-version.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@ import fs from 'fs/promises';
33
import path from 'path';
44

55
export async function npmVersion(increment, packageDirectory) {
6+
{
7+
const packageInfo = JSON.parse(await fs.readFile(path.join(packageDirectory, 'package.json')));
8+
if (packageInfo.version === '0.0.0') {
9+
switch (increment) {
10+
case 'major':
11+
packageInfo.version = '1.0.0';
12+
break;
13+
case 'minor':
14+
packageInfo.version = '0.1.0';
15+
break;
16+
case 'patch':
17+
packageInfo.version = '0.0.1';
18+
break;
19+
20+
default:
21+
throw new Error(`Unknown increment "${increment}"`);
22+
}
23+
24+
await fs.writeFile(path.join(packageDirectory, 'package.json'), JSON.stringify(packageInfo, null, '\t'));
25+
return packageInfo.version;
26+
}
27+
}
28+
629
await new Promise((resolve, reject) => {
730
const versionCmd = spawn(
831
'npm',

0 commit comments

Comments
 (0)