@hubspot/npm-scripts 0.3.1-beta.0 → 0.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/npm-scripts",
3
- "version": "0.3.1-beta.0",
3
+ "version": "0.3.2",
4
4
  "description": "Scripts for working with npm packages in the HubSpot ecosystem",
5
5
  "author": "",
6
6
  "license": "Apache-2.0",
@@ -388,7 +388,7 @@ describe('release handler', () => {
388
388
  skipBranchValidation: false,
389
389
  skipVersionCheck: true,
390
390
  });
391
- expect(updateNextTag).toHaveBeenCalledWith('@hubspot/test-package', expect.any(String), '123456', false, 'https://registry.npmjs.org/');
391
+ expect(updateNextTag).toHaveBeenCalledWith('@hubspot/test-package', expect.any(String), false, 'https://registry.npmjs.org/');
392
392
  });
393
393
  it('calls updatePreviousTag on a major latest release', async () => {
394
394
  const handler = setupAndGetHandler();
@@ -400,7 +400,7 @@ describe('release handler', () => {
400
400
  skipVersionCheck: true,
401
401
  });
402
402
  expect(updatePreviousTag).toHaveBeenCalledWith('@hubspot/test-package', '1.0.0', // currentLatestTag from getDistTags mock
403
- '123456', false, 'https://registry.npmjs.org/');
403
+ false, 'https://registry.npmjs.org/');
404
404
  });
405
405
  it('does not call updatePreviousTag on a non-major latest release', async () => {
406
406
  const handler = setupAndGetHandler();
package/src/release.js CHANGED
@@ -9,7 +9,7 @@ import { EXIT_CODES } from './utils/process.js';
9
9
  import { DEFAULT_MAIN_BRANCH, INCREMENT, PRERELEASE_IDENTIFIER, TAG, TAG_OPTIONS, VERSION_INCREMENT_OPTIONS, } from './constants/release.js';
10
10
  import { getCurrentGitBranch, gitCleanup } from './utils/git.js';
11
11
  import { getDistTags, publish, updateNextTag, updatePreviousTag, } from './utils/npm.js';
12
- import { confirm, input } from './utils/prompting.js';
12
+ import { confirm } from './utils/prompting.js';
13
13
  const exec = promisify(_exec);
14
14
  function buildHandler({ build, postLatestRelease, packageName, localVersion, registry, repositoryUrl, mainBranch, previousBranch, ignoreScripts, }) {
15
15
  return async function handler({ versionIncrement, tag, dryRun, skipBranchValidation, skipVersionCheck, }) {
@@ -121,7 +121,6 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
121
121
  await gitCleanup(newVersion, !isExperimental, onTempBranch ? tempBranch : undefined, onTempBranch ? branch : undefined);
122
122
  process.exit(EXIT_CODES.ERROR);
123
123
  }
124
- let otp = '';
125
124
  if (!isDryRun) {
126
125
  try {
127
126
  await exec(`npm whoami --registry ${registry}`);
@@ -135,15 +134,9 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
135
134
  process.exit(EXIT_CODES.ERROR);
136
135
  }
137
136
  }
138
- otp = await input({
139
- message: 'Enter your NPM one-time password:',
140
- });
141
- }
142
- else {
143
- logger.log('\nDry run: skipping one-time password entry');
144
137
  }
145
138
  try {
146
- await publish(tag, otp, isDryRun, ignoreScripts || false, registry);
139
+ await publish(tag, isDryRun, ignoreScripts || false, registry);
147
140
  }
148
141
  catch (e) {
149
142
  logger.error(e);
@@ -154,7 +147,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
154
147
  const gitCommand = `git push --atomic origin ${tempBranch} v${newVersion}`;
155
148
  if (tag === TAG.LATEST) {
156
149
  try {
157
- await updateNextTag(packageName, newVersion, otp, isDryRun, registry);
150
+ await updateNextTag(packageName, newVersion, isDryRun, registry);
158
151
  }
159
152
  catch (e) {
160
153
  logger.error(`An error occurred while updating the ${TAG.NEXT} tag. To finish this release, run the following commands:`);
@@ -163,7 +156,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
163
156
  }
164
157
  if (versionIncrement === INCREMENT.MAJOR) {
165
158
  try {
166
- await updatePreviousTag(packageName, currentLatestTag, otp, isDryRun, registry);
159
+ await updatePreviousTag(packageName, currentLatestTag, isDryRun, registry);
167
160
  }
168
161
  catch (e) {
169
162
  logger.error(`An error occurred while updating the ${TAG.PREVIOUS} tag. To finish this release, run the following command:`);
@@ -68,16 +68,8 @@ describe('npm', () => {
68
68
  }),
69
69
  };
70
70
  mockedSpawn.mockImplementation(() => mockChildProcess);
71
- await publish(TAG.LATEST, '123456', false, false, 'https://registry.npmjs.org/');
72
- expect(mockedSpawn).toHaveBeenCalledWith('npm', [
73
- 'publish',
74
- '--tag',
75
- TAG.LATEST,
76
- '--registry',
77
- 'https://registry.npmjs.org/',
78
- '--otp',
79
- '123456',
80
- ], {
71
+ await publish(TAG.LATEST, false, false, 'https://registry.npmjs.org/');
72
+ expect(mockedSpawn).toHaveBeenCalledWith('npm', ['publish', '--tag', TAG.LATEST, '--registry', 'https://registry.npmjs.org/'], {
81
73
  stdio: 'inherit',
82
74
  cwd: './dist',
83
75
  });
@@ -92,15 +84,13 @@ describe('npm', () => {
92
84
  }),
93
85
  };
94
86
  mockedSpawn.mockImplementation(() => mockChildProcess);
95
- await publish(TAG.NEXT, '123456', true, false, 'https://registry.npmjs.org/');
87
+ await publish(TAG.NEXT, true, false, 'https://registry.npmjs.org/');
96
88
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
97
89
  'publish',
98
90
  '--tag',
99
91
  TAG.NEXT,
100
92
  '--registry',
101
93
  'https://registry.npmjs.org/',
102
- '--otp',
103
- '123456',
104
94
  '--dry-run',
105
95
  ], {
106
96
  stdio: 'inherit',
@@ -117,15 +107,13 @@ describe('npm', () => {
117
107
  }),
118
108
  };
119
109
  mockedSpawn.mockImplementation(() => mockChildProcess);
120
- await publish(TAG.LATEST, '123456', false, true, 'https://registry.npmjs.org/');
110
+ await publish(TAG.LATEST, false, true, 'https://registry.npmjs.org/');
121
111
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
122
112
  'publish',
123
113
  '--tag',
124
114
  TAG.LATEST,
125
115
  '--registry',
126
116
  'https://registry.npmjs.org/',
127
- '--otp',
128
- '123456',
129
117
  '--ignore-scripts',
130
118
  ], {
131
119
  stdio: 'inherit',
@@ -142,15 +130,13 @@ describe('npm', () => {
142
130
  }),
143
131
  };
144
132
  mockedSpawn.mockImplementation(() => mockChildProcess);
145
- await publish(TAG.LATEST, '123456', true, true, 'https://registry.npmjs.org/');
133
+ await publish(TAG.LATEST, true, true, 'https://registry.npmjs.org/');
146
134
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
147
135
  'publish',
148
136
  '--tag',
149
137
  TAG.LATEST,
150
138
  '--registry',
151
139
  'https://registry.npmjs.org/',
152
- '--otp',
153
- '123456',
154
140
  '--dry-run',
155
141
  '--ignore-scripts',
156
142
  ], {
@@ -168,7 +154,7 @@ describe('npm', () => {
168
154
  }),
169
155
  };
170
156
  mockedSpawn.mockImplementation(() => mockChildProcess);
171
- await expect(publish(TAG.LATEST, '123456', false, false, 'https://registry.npmjs.org/')).rejects.toThrow('npm publish failed with exit code 1');
157
+ await expect(publish(TAG.LATEST, false, false, 'https://registry.npmjs.org/')).rejects.toThrow('npm publish failed with exit code 1');
172
158
  });
173
159
  });
174
160
  describe('updateDistTag', () => {
@@ -182,7 +168,7 @@ describe('npm', () => {
182
168
  }),
183
169
  };
184
170
  mockedSpawn.mockImplementation(() => mockChildProcess);
185
- await updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', '123456', false, 'https://registry.npmjs.org/');
171
+ await updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', false, 'https://registry.npmjs.org/');
186
172
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
187
173
  'dist-tag',
188
174
  'add',
@@ -190,13 +176,11 @@ describe('npm', () => {
190
176
  'custom-tag',
191
177
  '--registry',
192
178
  'https://registry.npmjs.org/',
193
- '--otp',
194
- '123456',
195
179
  ], { stdio: 'inherit' });
196
180
  expect(vi.mocked(logger.success)).toHaveBeenCalledWith('custom-tag tag updated successfully');
197
181
  });
198
182
  it('should skip execution and log dry run message when isDryRun is true', async () => {
199
- await updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', '123456', true, 'https://registry.npmjs.org/');
183
+ await updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', true, 'https://registry.npmjs.org/');
200
184
  expect(mockedSpawn).not.toHaveBeenCalled();
201
185
  expect(vi.mocked(logger.log)).toHaveBeenCalledWith(expect.stringContaining('Dry run: skipping run of'));
202
186
  });
@@ -210,7 +194,7 @@ describe('npm', () => {
210
194
  }),
211
195
  };
212
196
  mockedSpawn.mockImplementation(() => mockChildProcess);
213
- await expect(updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', '123456', false, 'https://registry.npmjs.org/')).rejects.toThrow('npm dist-tag add failed with exit code 1');
197
+ await expect(updateDistTag('@hubspot/test-package', '1.0.0', 'custom-tag', false, 'https://registry.npmjs.org/')).rejects.toThrow('npm dist-tag add failed with exit code 1');
214
198
  });
215
199
  });
216
200
  describe('updateNextTag', () => {
@@ -224,7 +208,7 @@ describe('npm', () => {
224
208
  }),
225
209
  };
226
210
  mockedSpawn.mockImplementation(() => mockChildProcess);
227
- await updateNextTag('@hubspot/test-package', '1.0.0', '123456', false, 'https://registry.npmjs.org/');
211
+ await updateNextTag('@hubspot/test-package', '1.0.0', false, 'https://registry.npmjs.org/');
228
212
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
229
213
  'dist-tag',
230
214
  'add',
@@ -232,8 +216,6 @@ describe('npm', () => {
232
216
  TAG.NEXT,
233
217
  '--registry',
234
218
  'https://registry.npmjs.org/',
235
- '--otp',
236
- '123456',
237
219
  ], { stdio: 'inherit' });
238
220
  expect(vi.mocked(logger.success)).toHaveBeenCalledWith(`${TAG.NEXT} tag updated successfully`);
239
221
  });
@@ -249,7 +231,7 @@ describe('npm', () => {
249
231
  }),
250
232
  };
251
233
  mockedSpawn.mockImplementation(() => mockChildProcess);
252
- await updatePreviousTag('@hubspot/test-package', '8.3.6', '123456', false, 'https://registry.npmjs.org/');
234
+ await updatePreviousTag('@hubspot/test-package', '8.3.6', false, 'https://registry.npmjs.org/');
253
235
  expect(mockedSpawn).toHaveBeenCalledWith('npm', [
254
236
  'dist-tag',
255
237
  'add',
@@ -257,8 +239,6 @@ describe('npm', () => {
257
239
  TAG.PREVIOUS,
258
240
  '--registry',
259
241
  'https://registry.npmjs.org/',
260
- '--otp',
261
- '123456',
262
242
  ], { stdio: 'inherit' });
263
243
  expect(vi.mocked(logger.success)).toHaveBeenCalledWith(`${TAG.PREVIOUS} tag updated successfully`);
264
244
  });
@@ -1,6 +1,6 @@
1
1
  import { DistTags, Tag } from '../types.js';
2
2
  export declare function getDistTags(packageName: string): Promise<DistTags>;
3
- export declare function publish(tag: Tag, otp: string, isDryRun: boolean, ignoreScripts: boolean, registry: string): Promise<void>;
4
- export declare function updateDistTag(packageName: string, version: string, tag: string, otp: string, isDryRun: boolean, registry: string): Promise<void>;
5
- export declare function updateNextTag(packageName: string, newVersion: string, otp: string, isDryRun: boolean, registry: string): Promise<void>;
6
- export declare function updatePreviousTag(packageName: string, oldLatestVersion: string, otp: string, isDryRun: boolean, registry: string): Promise<void>;
3
+ export declare function publish(tag: Tag, isDryRun: boolean, ignoreScripts: boolean, registry: string): Promise<void>;
4
+ export declare function updateDistTag(packageName: string, version: string, tag: string, isDryRun: boolean, registry: string): Promise<void>;
5
+ export declare function updateNextTag(packageName: string, newVersion: string, isDryRun: boolean, registry: string): Promise<void>;
6
+ export declare function updatePreviousTag(packageName: string, oldLatestVersion: string, isDryRun: boolean, registry: string): Promise<void>;
package/src/utils/npm.js CHANGED
@@ -9,19 +9,11 @@ export async function getDistTags(packageName) {
9
9
  const distTags = stdout.trim();
10
10
  return JSON.parse(distTags);
11
11
  }
12
- export async function publish(tag, otp, isDryRun, ignoreScripts, registry) {
12
+ export async function publish(tag, isDryRun, ignoreScripts, registry) {
13
13
  logger.log(`\nPublishing to ${tag}...`);
14
14
  logger.log('-'.repeat(50));
15
15
  logger.log('\n');
16
- const commandArgs = [
17
- 'publish',
18
- '--tag',
19
- tag,
20
- '--registry',
21
- registry,
22
- '--otp',
23
- otp,
24
- ];
16
+ const commandArgs = ['publish', '--tag', tag, '--registry', registry];
25
17
  if (isDryRun) {
26
18
  commandArgs.push('--dry-run');
27
19
  }
@@ -43,7 +35,7 @@ export async function publish(tag, otp, isDryRun, ignoreScripts, registry) {
43
35
  });
44
36
  });
45
37
  }
46
- export async function updateDistTag(packageName, version, tag, otp, isDryRun, registry) {
38
+ export async function updateDistTag(packageName, version, tag, isDryRun, registry) {
47
39
  logger.log();
48
40
  logger.log(`Updating ${tag} tag to ${version}...`);
49
41
  const commandArgs = [
@@ -53,8 +45,6 @@ export async function updateDistTag(packageName, version, tag, otp, isDryRun, re
53
45
  tag,
54
46
  '--registry',
55
47
  registry,
56
- '--otp',
57
- otp,
58
48
  ];
59
49
  return new Promise((resolve, reject) => {
60
50
  if (isDryRun) {
@@ -76,9 +66,9 @@ export async function updateDistTag(packageName, version, tag, otp, isDryRun, re
76
66
  }
77
67
  });
78
68
  }
79
- export async function updateNextTag(packageName, newVersion, otp, isDryRun, registry) {
80
- return updateDistTag(packageName, newVersion, TAG.NEXT, otp, isDryRun, registry);
69
+ export async function updateNextTag(packageName, newVersion, isDryRun, registry) {
70
+ return updateDistTag(packageName, newVersion, TAG.NEXT, isDryRun, registry);
81
71
  }
82
- export async function updatePreviousTag(packageName, oldLatestVersion, otp, isDryRun, registry) {
83
- return updateDistTag(packageName, oldLatestVersion, TAG.PREVIOUS, otp, isDryRun, registry);
72
+ export async function updatePreviousTag(packageName, oldLatestVersion, isDryRun, registry) {
73
+ return updateDistTag(packageName, oldLatestVersion, TAG.PREVIOUS, isDryRun, registry);
84
74
  }