@hubspot/npm-scripts 0.0.5-experimental.2 → 0.0.5-experimental.4
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/vscode-release.js +27 -15
package/package.json
CHANGED
package/src/vscode-release.js
CHANGED
|
@@ -7,7 +7,7 @@ import fs from 'fs-extra';
|
|
|
7
7
|
import { logger } from './utils/logging.js';
|
|
8
8
|
import { EXIT_CODES } from './utils/process.js';
|
|
9
9
|
import { DEFAULT_MAIN_BRANCH, VSCODE_VERSION_INCREMENT_OPTIONS, } from './constants/release.js';
|
|
10
|
-
import { getCurrentGitBranch } from './utils/git.js';
|
|
10
|
+
import { commitChanges, createBranch, getCurrentGitBranch, pushBranch, } 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, }) {
|
|
@@ -32,6 +32,20 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
32
32
|
logger.warn('No git tags found, skipping version check.');
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
let vsceCmd = 'vsce';
|
|
36
|
+
try {
|
|
37
|
+
await exec('vsce --version');
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
logger.log('Installing @vscode/vsce...');
|
|
41
|
+
await exec('yarn global add @vscode/vsce');
|
|
42
|
+
try {
|
|
43
|
+
await exec('vsce --version');
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
vsceCmd = 'npx @vscode/vsce';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
35
49
|
const newVersion = semver.inc(localVersion, versionIncrement);
|
|
36
50
|
if (!newVersion) {
|
|
37
51
|
logger.error('Error incrementing version.');
|
|
@@ -50,7 +64,6 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
50
64
|
}
|
|
51
65
|
const userHasTested = await confirm({
|
|
52
66
|
message: 'Have you tested the pre-release package locally?',
|
|
53
|
-
default: false,
|
|
54
67
|
});
|
|
55
68
|
if (!userHasTested) {
|
|
56
69
|
logger.log('\nBuilding and packaging the pre-release for testing...\n');
|
|
@@ -64,7 +77,7 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
64
77
|
await exec('yarn lint');
|
|
65
78
|
}
|
|
66
79
|
logger.log('\nPackaging pre-release...');
|
|
67
|
-
await exec(
|
|
80
|
+
await exec(`mkdir -p releases && ${vsceCmd} package --pre-release -o releases/`);
|
|
68
81
|
logger.success('Pre-release package created.');
|
|
69
82
|
logger.log('\nTo test the package locally:');
|
|
70
83
|
logger.log(' 1. Open VS Code');
|
|
@@ -74,7 +87,6 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
74
87
|
logger.log(' 5. Test key functionality\n');
|
|
75
88
|
const readyToContinue = await confirm({
|
|
76
89
|
message: 'Continue when you have finished testing the pre-release.',
|
|
77
|
-
default: false,
|
|
78
90
|
});
|
|
79
91
|
if (!readyToContinue) {
|
|
80
92
|
logger.log('Release aborted.');
|
|
@@ -85,35 +97,35 @@ function buildHandler({ build, packageName, localVersion, mainBranch, }) {
|
|
|
85
97
|
await exec(`yarn version --no-git-tag-version --new-version ${newVersion}`);
|
|
86
98
|
logger.success('Version updated in package.json');
|
|
87
99
|
logger.log('\nPackaging regular release...');
|
|
88
|
-
await exec(
|
|
100
|
+
await exec(`mkdir -p releases && ${vsceCmd} package -o releases/`);
|
|
89
101
|
logger.success('Regular release package created.');
|
|
90
102
|
const confirmRegularRelease = await confirm({
|
|
91
103
|
message: 'Test the regular release .vsix and confirm it works. Ready to proceed?',
|
|
92
|
-
default: false,
|
|
93
104
|
});
|
|
94
105
|
if (!confirmRegularRelease) {
|
|
95
106
|
logger.log('Release aborted after regular release packaging.');
|
|
96
107
|
logger.log('Note: package.json version has been updated locally. Revert if needed.');
|
|
97
108
|
process.exit(EXIT_CODES.SUCCESS);
|
|
98
109
|
}
|
|
99
|
-
const
|
|
110
|
+
const tempBranch = `v${newVersion}-publish`;
|
|
100
111
|
if (isDryRun) {
|
|
101
112
|
logger.log('\nDry run complete. Would have:');
|
|
102
|
-
logger.log(` 1. Created branch ${
|
|
113
|
+
logger.log(` 1. Created branch ${tempBranch}`);
|
|
103
114
|
logger.log(` 2. Committed package.json version bump`);
|
|
104
|
-
logger.log(` 3. Pushed ${
|
|
115
|
+
logger.log(` 3. Pushed ${tempBranch} to origin`);
|
|
105
116
|
logger.log(` 4. Created draft PR against ${mainBranch}`);
|
|
106
117
|
logger.log(` 5. Created draft GH release v${newVersion}`);
|
|
107
118
|
logger.log(` 6. Opened VS Code Marketplace for .vsix upload`);
|
|
108
119
|
process.exit(EXIT_CODES.SUCCESS);
|
|
109
120
|
}
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
if (branch === mainBranch && !isDryRun) {
|
|
122
|
+
logger.log(`\nCreating release branch ${tempBranch}...`);
|
|
123
|
+
await createBranch(tempBranch);
|
|
124
|
+
}
|
|
112
125
|
logger.log('Committing changes...');
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
await exec(`git push -u origin ${releaseBranch}`);
|
|
126
|
+
await commitChanges(`Bump version to ${newVersion}`);
|
|
127
|
+
logger.log(`Pushing ${tempBranch}...`);
|
|
128
|
+
await pushBranch(tempBranch);
|
|
117
129
|
logger.log('\nCreating draft pull request...');
|
|
118
130
|
const { stdout: prUrl } = await exec(`gh pr create --draft --base ${mainBranch} --title "Release v${newVersion}" --body "## Release v${newVersion}"`);
|
|
119
131
|
logger.success(`Draft PR created: ${prUrl.trim()}`);
|