@hubspot/npm-scripts 0.0.5-experimental.1 → 0.0.5-experimental.2
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 +51 -35
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,27 @@ 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
|
+
}
|
|
22
35
|
const newVersion = semver.inc(localVersion, versionIncrement);
|
|
23
36
|
if (!newVersion) {
|
|
24
37
|
logger.error('Error incrementing version.');
|
|
@@ -35,39 +48,37 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
35
48
|
if (!shouldRelease) {
|
|
36
49
|
process.exit(EXIT_CODES.SUCCESS);
|
|
37
50
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
const userHasTested = await confirm({
|
|
52
|
+
message: 'Have you tested the pre-release package locally?',
|
|
53
|
+
default: false,
|
|
54
|
+
});
|
|
55
|
+
if (!userHasTested) {
|
|
56
|
+
logger.log('\nBuilding and packaging the pre-release for testing...\n');
|
|
57
|
+
if (build && typeof build === 'function') {
|
|
58
|
+
await build();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
logger.log('Installing dependencies...');
|
|
62
|
+
await exec('yarn install');
|
|
63
|
+
logger.log('Running linting...');
|
|
64
|
+
await exec('yarn lint');
|
|
65
|
+
}
|
|
66
|
+
logger.log('\nPackaging pre-release...');
|
|
67
|
+
await exec('npx vsce package --pre-release -o releases/');
|
|
68
|
+
logger.success('Pre-release package created.');
|
|
69
|
+
logger.log('\nTo test the package locally:');
|
|
70
|
+
logger.log(' 1. Open VS Code');
|
|
71
|
+
logger.log(' 2. Go to the Extensions panel');
|
|
72
|
+
logger.log(' 3. Click "..." menu → "Install from VSIX..."');
|
|
73
|
+
logger.log(' 4. Select the .vsix file created above');
|
|
74
|
+
logger.log(' 5. Test key functionality\n');
|
|
75
|
+
const readyToContinue = await confirm({
|
|
76
|
+
message: 'Continue when you have finished testing the pre-release.',
|
|
41
77
|
default: false,
|
|
42
78
|
});
|
|
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
|
-
}
|
|
79
|
+
if (!readyToContinue) {
|
|
80
|
+
logger.log('Release aborted.');
|
|
81
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
84
|
logger.log(`\nUpdating version to ${newVersion}...`);
|
|
@@ -136,8 +147,13 @@ async function builder(yargs) {
|
|
|
136
147
|
default: false,
|
|
137
148
|
type: 'boolean',
|
|
138
149
|
},
|
|
139
|
-
|
|
140
|
-
describe: '
|
|
150
|
+
skipBranchValidation: {
|
|
151
|
+
describe: 'Bypass the branch validation check',
|
|
152
|
+
default: false,
|
|
153
|
+
type: 'boolean',
|
|
154
|
+
},
|
|
155
|
+
skipVersionCheck: {
|
|
156
|
+
describe: 'Bypass checking that the local version matches the published version',
|
|
141
157
|
default: false,
|
|
142
158
|
type: 'boolean',
|
|
143
159
|
},
|