@hubspot/npm-scripts 0.0.5-experimental.1 → 0.0.5-experimental.3
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 +1 -1
- package/src/types.d.ts +2 -1
- package/src/vscode-release.js +59 -36
package/package.json
CHANGED
package/src/types.d.ts
CHANGED
|
@@ -37,7 +37,8 @@ export interface BuildReleaseScriptOptions extends BuildReleaseScriptBase {
|
|
|
37
37
|
export type VscodeReleaseArguments = {
|
|
38
38
|
versionIncrement: (typeof VSCODE_VERSION_INCREMENT_OPTIONS)[number];
|
|
39
39
|
dryRun: boolean;
|
|
40
|
-
|
|
40
|
+
skipBranchValidation: boolean;
|
|
41
|
+
skipVersionCheck: boolean;
|
|
41
42
|
};
|
|
42
43
|
export interface VscodeReleaseScriptBase {
|
|
43
44
|
mainBranch?: string;
|
package/src/vscode-release.js
CHANGED
|
@@ -11,14 +11,34 @@ import { getCurrentGitBranch } from './utils/git.js';
|
|
|
11
11
|
import { confirm } from './utils/prompting.js';
|
|
12
12
|
const exec = promisify(_exec);
|
|
13
13
|
function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
14
|
-
return async function handler({ versionIncrement, dryRun,
|
|
14
|
+
return async function handler({ versionIncrement, dryRun, skipBranchValidation, skipVersionCheck, }) {
|
|
15
15
|
try {
|
|
16
16
|
const branch = await getCurrentGitBranch();
|
|
17
17
|
const isDryRun = Boolean(dryRun);
|
|
18
|
-
if (branch !== mainBranch) {
|
|
18
|
+
if (!skipBranchValidation && branch !== mainBranch) {
|
|
19
19
|
logger.error(`Releases can only be published from the ${mainBranch} branch. Current branch: ${branch}`);
|
|
20
20
|
process.exit(EXIT_CODES.ERROR);
|
|
21
21
|
}
|
|
22
|
+
if (!skipVersionCheck) {
|
|
23
|
+
try {
|
|
24
|
+
const { stdout: lastTag } = await exec('git describe --tags --abbrev=0');
|
|
25
|
+
const lastTagVersion = lastTag.trim().replace(/^v/, '');
|
|
26
|
+
if (lastTagVersion !== localVersion) {
|
|
27
|
+
logger.error(`Local package.json version ${localVersion} is out of sync with the latest git tag v${lastTagVersion}`);
|
|
28
|
+
process.exit(EXIT_CODES.ERROR);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
logger.warn('No git tags found, skipping version check.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await exec('vsce --version');
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
logger.log('Installing @vscode/vsce...');
|
|
40
|
+
await exec('yarn global add @vscode/vsce');
|
|
41
|
+
}
|
|
22
42
|
const newVersion = semver.inc(localVersion, versionIncrement);
|
|
23
43
|
if (!newVersion) {
|
|
24
44
|
logger.error('Error incrementing version.');
|
|
@@ -35,46 +55,44 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
35
55
|
if (!shouldRelease) {
|
|
36
56
|
process.exit(EXIT_CODES.SUCCESS);
|
|
37
57
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
const userHasTested = await confirm({
|
|
59
|
+
message: 'Have you tested the pre-release package locally?',
|
|
60
|
+
default: false,
|
|
61
|
+
});
|
|
62
|
+
if (!userHasTested) {
|
|
63
|
+
logger.log('\nBuilding and packaging the pre-release for testing...\n');
|
|
64
|
+
if (build && typeof build === 'function') {
|
|
65
|
+
await build();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
logger.log('Installing dependencies...');
|
|
69
|
+
await exec('yarn install');
|
|
70
|
+
logger.log('Running linting...');
|
|
71
|
+
await exec('yarn lint');
|
|
72
|
+
}
|
|
73
|
+
logger.log('\nPackaging pre-release...');
|
|
74
|
+
await exec('mkdir -p releases && vsce package --pre-release -o releases/');
|
|
75
|
+
logger.success('Pre-release package created.');
|
|
76
|
+
logger.log('\nTo test the package locally:');
|
|
77
|
+
logger.log(' 1. Open VS Code');
|
|
78
|
+
logger.log(' 2. Go to the Extensions panel');
|
|
79
|
+
logger.log(' 3. Click "..." menu → "Install from VSIX..."');
|
|
80
|
+
logger.log(' 4. Select the .vsix file created above');
|
|
81
|
+
logger.log(' 5. Test key functionality\n');
|
|
82
|
+
const readyToContinue = await confirm({
|
|
83
|
+
message: 'Continue when you have finished testing the pre-release.',
|
|
41
84
|
default: false,
|
|
42
85
|
});
|
|
43
|
-
if (!
|
|
44
|
-
logger.log('
|
|
45
|
-
|
|
46
|
-
await build();
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
logger.log('Installing dependencies...');
|
|
50
|
-
await exec('yarn install');
|
|
51
|
-
logger.log('Running linting...');
|
|
52
|
-
await exec('yarn lint');
|
|
53
|
-
}
|
|
54
|
-
logger.log('\nPackaging pre-release...');
|
|
55
|
-
await exec('npx vsce package --pre-release -o releases/');
|
|
56
|
-
logger.success('Pre-release package created.');
|
|
57
|
-
logger.log('\nTo test the package locally:');
|
|
58
|
-
logger.log(' 1. Open VS Code');
|
|
59
|
-
logger.log(' 2. Go to the Extensions panel');
|
|
60
|
-
logger.log(' 3. Click "..." menu → "Install from VSIX..."');
|
|
61
|
-
logger.log(' 4. Select the .vsix file created above');
|
|
62
|
-
logger.log(' 5. Test key functionality\n');
|
|
63
|
-
const readyToContinue = await confirm({
|
|
64
|
-
message: 'Continue when you have finished testing the pre-release.',
|
|
65
|
-
default: false,
|
|
66
|
-
});
|
|
67
|
-
if (!readyToContinue) {
|
|
68
|
-
logger.log('Release aborted.');
|
|
69
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
70
|
-
}
|
|
86
|
+
if (!readyToContinue) {
|
|
87
|
+
logger.log('Release aborted.');
|
|
88
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
91
|
logger.log(`\nUpdating version to ${newVersion}...`);
|
|
74
92
|
await exec(`yarn version --no-git-tag-version --new-version ${newVersion}`);
|
|
75
93
|
logger.success('Version updated in package.json');
|
|
76
94
|
logger.log('\nPackaging regular release...');
|
|
77
|
-
await exec('
|
|
95
|
+
await exec('mkdir -p releases && vsce package -o releases/');
|
|
78
96
|
logger.success('Regular release package created.');
|
|
79
97
|
const confirmRegularRelease = await confirm({
|
|
80
98
|
message: 'Test the regular release .vsix and confirm it works. Ready to proceed?',
|
|
@@ -136,8 +154,13 @@ async function builder(yargs) {
|
|
|
136
154
|
default: false,
|
|
137
155
|
type: 'boolean',
|
|
138
156
|
},
|
|
139
|
-
|
|
140
|
-
describe: '
|
|
157
|
+
skipBranchValidation: {
|
|
158
|
+
describe: 'Bypass the branch validation check',
|
|
159
|
+
default: false,
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
},
|
|
162
|
+
skipVersionCheck: {
|
|
163
|
+
describe: 'Bypass checking that the local version matches the published version',
|
|
141
164
|
default: false,
|
|
142
165
|
type: 'boolean',
|
|
143
166
|
},
|