@hubspot/npm-scripts 0.0.1-experimental.0 → 0.0.2-experimental.1
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/README.md +1 -1
- package/package.json +1 -1
- package/src/linking.js +3 -3
- package/src/release.js +5 -4
- package/src/utils/git.d.ts +1 -1
- package/src/utils/git.js +4 -2
- package/src/utils/prompting.d.ts +6 -0
- package/src/utils/prompting.js +38 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/linking.js
CHANGED
|
@@ -2,7 +2,7 @@ import os from 'os';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { execSync } from 'node:child_process';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import { checkbox } from '
|
|
5
|
+
import { checkbox } from './utils/prompting.js';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
7
|
import findup from 'findup-sync';
|
|
8
8
|
import { logger } from './utils/logging.js';
|
|
@@ -47,10 +47,10 @@ const yarnLinkPath = path.join(os.homedir(), '.config', 'yarn', 'link', hubspotP
|
|
|
47
47
|
}
|
|
48
48
|
let packagesToLink = [];
|
|
49
49
|
try {
|
|
50
|
-
packagesToLink = await checkbox({
|
|
50
|
+
packagesToLink = (await checkbox({
|
|
51
51
|
message: 'Which packages would you like to link? - To get packages to show in this list, run `yarn link` from inside the local copy that package.',
|
|
52
52
|
choices,
|
|
53
|
-
});
|
|
53
|
+
}));
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
56
|
if (e instanceof Error && e.name === 'ExitPromptError') {
|
package/src/release.js
CHANGED
|
@@ -3,13 +3,13 @@ import { promisify } from 'util';
|
|
|
3
3
|
import yargs from 'yargs';
|
|
4
4
|
import semver from 'semver';
|
|
5
5
|
import open from 'open';
|
|
6
|
+
import fs from 'fs-extra';
|
|
6
7
|
import { logger } from './utils/logging.js';
|
|
7
8
|
import { EXIT_CODES } from './utils/process.js';
|
|
8
9
|
import { DEFAULT_MAIN_BRANCH, INCREMENT, PRERELEASE_IDENTIFIER, TAG, TAG_OPTIONS, VERSION_INCREMENT_OPTIONS, } from './constants/release.js';
|
|
9
|
-
import { confirm, input } from '@inquirer/prompts';
|
|
10
|
-
import fs from 'fs-extra';
|
|
11
10
|
import { gitCleanup, getCurrentGitBranch } from './utils/git.js';
|
|
12
11
|
import { getDistTags, publish, updateNextTag } from './utils/npm.js';
|
|
12
|
+
import { confirm, input } from './utils/prompting.js';
|
|
13
13
|
const exec = promisify(_exec);
|
|
14
14
|
function buildHandler({ build, postLatestRelease, packageName, localVersion, registry, repositoryUrl, mainBranch, }) {
|
|
15
15
|
return async function handler({ versionIncrement, tag, dryRun, }) {
|
|
@@ -101,8 +101,9 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
|
|
|
101
101
|
await publish(tag, otp, isDryRun, registry);
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
|
+
logger.error(e);
|
|
104
105
|
logger.error('An error occurred while releasing the CLI. Correct the error and re-run `yarn build`.');
|
|
105
|
-
await gitCleanup(newVersion);
|
|
106
|
+
await gitCleanup(newVersion, !isExperimental);
|
|
106
107
|
process.exit(EXIT_CODES.ERROR);
|
|
107
108
|
}
|
|
108
109
|
const gitCommand = `git push --atomic origin ${tempBranch} v${newVersion}`;
|
|
@@ -117,7 +118,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
if (isDryRun) {
|
|
120
|
-
await gitCleanup(newVersion);
|
|
121
|
+
await gitCleanup(newVersion, !isExperimental);
|
|
121
122
|
logger.log(`\nDry run: skipping push to Github`);
|
|
122
123
|
logger.log('Dry run release finished successfully');
|
|
123
124
|
process.exit(EXIT_CODES.SUCCESS);
|
package/src/utils/git.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function getCurrentGitBranch(): Promise<string>;
|
|
2
|
-
export declare function gitCleanup(newVersion: string): Promise<void>;
|
|
2
|
+
export declare function gitCleanup(newVersion: string, deleteTag: boolean): Promise<void>;
|
package/src/utils/git.js
CHANGED
|
@@ -5,8 +5,10 @@ export async function getCurrentGitBranch() {
|
|
|
5
5
|
const { stdout } = await exec('git rev-parse --abbrev-ref HEAD');
|
|
6
6
|
return stdout.trim();
|
|
7
7
|
}
|
|
8
|
-
export async function gitCleanup(newVersion) {
|
|
8
|
+
export async function gitCleanup(newVersion, deleteTag) {
|
|
9
9
|
await exec(`git reset HEAD~`);
|
|
10
10
|
await exec(`git checkout .`);
|
|
11
|
-
|
|
11
|
+
if (deleteTag) {
|
|
12
|
+
await exec(`git tag -d v${newVersion}`);
|
|
13
|
+
}
|
|
12
14
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import _confirm from '@inquirer/confirm';
|
|
2
|
+
import _input from '@inquirer/input';
|
|
3
|
+
import _checkbox from '@inquirer/checkbox';
|
|
4
|
+
export declare function confirm(...args: Parameters<typeof _confirm>): Promise<ReturnType<typeof _confirm>>;
|
|
5
|
+
export declare function input(...args: Parameters<typeof _input>): Promise<ReturnType<typeof _input>>;
|
|
6
|
+
export declare function checkbox(...args: Parameters<typeof _checkbox>): Promise<ReturnType<typeof _checkbox>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _confirm from '@inquirer/confirm';
|
|
2
|
+
import _input from '@inquirer/input';
|
|
3
|
+
import _checkbox from '@inquirer/checkbox';
|
|
4
|
+
import { EXIT_CODES } from './process.js';
|
|
5
|
+
import { logger } from './logging.js';
|
|
6
|
+
function exitIfPromptError(e) {
|
|
7
|
+
if (e instanceof Error && e.name === 'ExitPromptError') {
|
|
8
|
+
logger.log('Exiting...');
|
|
9
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export async function confirm(...args) {
|
|
13
|
+
try {
|
|
14
|
+
return await _confirm(...args);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
exitIfPromptError(e);
|
|
18
|
+
throw e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function input(...args) {
|
|
22
|
+
try {
|
|
23
|
+
return await _input(...args);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
exitIfPromptError(e);
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function checkbox(...args) {
|
|
31
|
+
try {
|
|
32
|
+
return await _checkbox(...args);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
exitIfPromptError(e);
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
}
|