@hubspot/npm-scripts 0.0.2-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/npm-scripts",
3
- "version": "0.0.2-experimental.0",
3
+ "version": "0.0.2-experimental.1",
4
4
  "description": "Scripts for working with npm packages in the HubSpot ecosystem",
5
5
  "author": "",
6
6
  "license": "Apache-2.0",
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 '@inquirer/prompts';
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, }) {
@@ -103,7 +103,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
103
103
  catch (e) {
104
104
  logger.error(e);
105
105
  logger.error('An error occurred while releasing the CLI. Correct the error and re-run `yarn build`.');
106
- await gitCleanup(newVersion);
106
+ await gitCleanup(newVersion, !isExperimental);
107
107
  process.exit(EXIT_CODES.ERROR);
108
108
  }
109
109
  const gitCommand = `git push --atomic origin ${tempBranch} v${newVersion}`;
@@ -118,9 +118,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
118
118
  }
119
119
  }
120
120
  if (isDryRun) {
121
- if (!isExperimental) {
122
- await gitCleanup(newVersion);
123
- }
121
+ await gitCleanup(newVersion, !isExperimental);
124
122
  logger.log(`\nDry run: skipping push to Github`);
125
123
  logger.log('Dry run release finished successfully');
126
124
  process.exit(EXIT_CODES.SUCCESS);
@@ -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
- await exec(`git tag -d v${newVersion}`);
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
+ }