@hubspot/npm-scripts 0.0.6 → 0.0.7-experimental.0

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.
Files changed (48) hide show
  1. package/README.md +72 -2
  2. package/package.json +8 -4
  3. package/src/__tests__/release.test.d.ts +1 -0
  4. package/src/__tests__/release.test.js +494 -0
  5. package/src/constants/release.d.ts +2 -1
  6. package/src/constants/release.js +7 -1
  7. package/src/constants/repo-sync.d.ts +5 -0
  8. package/src/constants/repo-sync.js +5 -0
  9. package/src/release/__tests__/steps.test.d.ts +1 -0
  10. package/src/release/__tests__/steps.test.js +382 -0
  11. package/src/release/__tests__/validate.test.d.ts +1 -0
  12. package/src/release/__tests__/validate.test.js +148 -0
  13. package/src/release/__tests__/version.test.d.ts +1 -0
  14. package/src/release/__tests__/version.test.js +104 -0
  15. package/src/release/errors.d.ts +4 -0
  16. package/src/release/errors.js +9 -0
  17. package/src/release/steps.d.ts +11 -0
  18. package/src/release/steps.js +159 -0
  19. package/src/release/types.d.ts +80 -0
  20. package/src/release/types.js +1 -0
  21. package/src/release/validate.d.ts +6 -0
  22. package/src/release/validate.js +33 -0
  23. package/src/release/version.d.ts +2 -0
  24. package/src/release/version.js +23 -0
  25. package/src/release.d.ts +1 -1
  26. package/src/release.js +112 -146
  27. package/src/repo-sync.d.ts +5 -0
  28. package/src/repo-sync.js +141 -0
  29. package/src/types.d.ts +18 -0
  30. package/src/utils/__tests__/filesystem.test.d.ts +1 -0
  31. package/src/utils/__tests__/filesystem.test.js +154 -0
  32. package/src/utils/__tests__/git.test.d.ts +1 -0
  33. package/src/utils/__tests__/git.test.js +292 -0
  34. package/src/utils/__tests__/logging.test.d.ts +1 -0
  35. package/src/utils/__tests__/logging.test.js +64 -0
  36. package/src/utils/__tests__/npm.test.d.ts +1 -0
  37. package/src/utils/__tests__/npm.test.js +246 -0
  38. package/src/utils/__tests__/process.test.d.ts +1 -0
  39. package/src/utils/__tests__/process.test.js +12 -0
  40. package/src/utils/__tests__/prompting.test.d.ts +1 -0
  41. package/src/utils/__tests__/prompting.test.js +100 -0
  42. package/src/utils/filesystem.d.ts +1 -0
  43. package/src/utils/filesystem.js +72 -0
  44. package/src/utils/git.d.ts +7 -1
  45. package/src/utils/git.js +112 -3
  46. package/src/utils/logging.js +2 -2
  47. package/src/utils/npm.d.ts +4 -2
  48. package/src/utils/npm.js +18 -19
package/src/utils/npm.js CHANGED
@@ -9,22 +9,17 @@ 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, 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
  }
20
+ if (ignoreScripts) {
21
+ commandArgs.push('--ignore-scripts');
22
+ }
28
23
  return new Promise((resolve, reject) => {
29
24
  const childProcess = spawn('npm', commandArgs, {
30
25
  stdio: 'inherit',
@@ -32,7 +27,7 @@ export async function publish(tag, otp, isDryRun, registry) {
32
27
  });
33
28
  childProcess.on('close', code => {
34
29
  if (code !== EXIT_CODES.SUCCESS) {
35
- reject();
30
+ reject(new Error(`npm publish failed with exit code ${code}`));
36
31
  }
37
32
  else {
38
33
  resolve();
@@ -40,18 +35,16 @@ export async function publish(tag, otp, isDryRun, registry) {
40
35
  });
41
36
  });
42
37
  }
43
- export async function updateNextTag(packageName, newVersion, otp, isDryRun, registry) {
38
+ export async function updateDistTag(packageName, version, tag, isDryRun, registry) {
44
39
  logger.log();
45
- logger.log(`Updating ${TAG.NEXT} tag...`);
40
+ logger.log(`Updating ${tag} tag to ${version}...`);
46
41
  const commandArgs = [
47
42
  'dist-tag',
48
43
  'add',
49
- `${packageName}@${newVersion}`,
50
- TAG.NEXT,
44
+ `${packageName}@${version}`,
45
+ tag,
51
46
  '--registry',
52
47
  registry,
53
- '--otp',
54
- otp,
55
48
  ];
56
49
  return new Promise((resolve, reject) => {
57
50
  if (isDryRun) {
@@ -63,13 +56,19 @@ export async function updateNextTag(packageName, newVersion, otp, isDryRun, regi
63
56
  const childProcess = spawn('npm', commandArgs, { stdio: 'inherit' });
64
57
  childProcess.on('close', code => {
65
58
  if (code !== EXIT_CODES.SUCCESS) {
66
- reject();
59
+ reject(new Error(`npm dist-tag add failed with exit code ${code}`));
67
60
  }
68
61
  else {
69
- logger.success(`${TAG.NEXT} tag updated successfully`);
62
+ logger.success(`${tag} tag updated successfully`);
70
63
  resolve();
71
64
  }
72
65
  });
73
66
  }
74
67
  });
75
68
  }
69
+ export async function updateNextTag(packageName, newVersion, isDryRun, registry) {
70
+ return updateDistTag(packageName, newVersion, TAG.NEXT, isDryRun, registry);
71
+ }
72
+ export async function updatePreviousTag(packageName, oldLatestVersion, isDryRun, registry) {
73
+ return updateDistTag(packageName, oldLatestVersion, TAG.PREVIOUS, isDryRun, registry);
74
+ }