@hubspot/npm-scripts 0.0.3 → 0.0.4-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/npm-scripts",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-experimental.0",
4
4
  "description": "Scripts for working with npm packages in the HubSpot ecosystem",
5
5
  "author": "",
6
6
  "license": "Apache-2.0",
@@ -23,7 +23,7 @@
23
23
  "fs-extra": "^11.3.2",
24
24
  "open": "^10.2.0",
25
25
  "semver": "^7.7.2",
26
- "yargs": "^18.0.0"
26
+ "yargs": "17.7.2"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@eslint/js": "^9.36.0",
@@ -38,7 +38,7 @@
38
38
  "eslint-plugin-import": "^2.32.0",
39
39
  "globals": "^16.4.0",
40
40
  "husky": "^4.3.8",
41
- "lint-staged": "^16.2.1",
41
+ "lint-staged": "^15.2.10",
42
42
  "prettier": "^3.6.2",
43
43
  "tsx": "^4.20.5",
44
44
  "typescript": "^5.6.2"
package/src/linking.js CHANGED
@@ -19,10 +19,19 @@ function getSymLinksInDirectory(directory) {
19
19
  });
20
20
  }
21
21
  function getPackageName(node_modules_dir, packages) {
22
- return packages.map((item) => {
23
- const { name } = fs.readJsonSync(path.join(node_modules_dir, item, packageJson));
24
- return name;
25
- });
22
+ return packages
23
+ .map((item) => {
24
+ const pathToOpen = path.join(node_modules_dir, item, packageJson);
25
+ try {
26
+ const { name } = fs.readJsonSync(pathToOpen);
27
+ return name;
28
+ }
29
+ catch (err) {
30
+ logger.warn(`Unable to open "${pathToOpen}", if @hubspot/${item} is a dependency of this project it is not installed. If you would like to link it, add it as a project dependency and install it.\n`);
31
+ return undefined;
32
+ }
33
+ })
34
+ .filter((item) => item !== undefined);
26
35
  }
27
36
  const yarnLinkPath = path.join(os.homedir(), '.config', 'yarn', 'link', hubspotPackageNamespace);
28
37
  (async () => {
package/src/release.js CHANGED
@@ -1,4 +1,4 @@
1
- import { exec as _exec } from 'node:child_process';
1
+ import { exec as _exec, execSync } from 'node:child_process';
2
2
  import { promisify } from 'util';
3
3
  import yargs from 'yargs';
4
4
  import semver from 'semver';
@@ -90,6 +90,20 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
90
90
  }
91
91
  let otp = '';
92
92
  if (!isDryRun) {
93
+ try {
94
+ await exec('npm logout');
95
+ const result = await exec(`npm whoami --registry ${registry}`, {
96
+ env: process.env,
97
+ });
98
+ console.log(result);
99
+ // console.log('stderr', stderr);
100
+ // if (stderr.includes('npm adduser')) {
101
+ // execSync('npm adduser', { stdio: 'inherit' });
102
+ // }
103
+ }
104
+ catch (err) {
105
+ execSync(`npm adduser --registry ${registry}`, { stdio: 'inherit' });
106
+ }
93
107
  otp = await input({
94
108
  message: 'Enter your NPM one-time password:',
95
109
  });
@@ -140,7 +154,7 @@ function buildHandler({ build, postLatestRelease, packageName, localVersion, reg
140
154
  logger.log(`\nRemember to create a new release on Github!`);
141
155
  await open(`${repositoryUrl}/releases/new`);
142
156
  if (postLatestRelease && typeof postLatestRelease === 'function') {
143
- await postLatestRelease();
157
+ await postLatestRelease({ newVersion, dryRun });
144
158
  }
145
159
  }
146
160
  };
@@ -162,6 +176,7 @@ async function builder(yargs) {
162
176
  dryRun: {
163
177
  alias: 'd',
164
178
  describe: 'Run through the publish process without actually publishing',
179
+ default: false,
165
180
  type: 'boolean',
166
181
  },
167
182
  });
package/src/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import { TAG, TAG_OPTIONS, VERSION_INCREMENT_OPTIONS } from './constants/release
2
2
  export type ReleaseArguments = {
3
3
  versionIncrement: (typeof VERSION_INCREMENT_OPTIONS)[number];
4
4
  tag: (typeof TAG_OPTIONS)[number];
5
- dryRun?: boolean;
5
+ dryRun: boolean;
6
6
  };
7
7
  export type DistTags = {
8
8
  [TAG.LATEST]: string;
@@ -12,7 +12,10 @@ export type DistTags = {
12
12
  export type Tag = (typeof TAG_OPTIONS)[number];
13
13
  export interface BuildReleaseScriptBase {
14
14
  build?: () => Promise<void> | void;
15
- postLatestRelease?: () => Promise<void> | void;
15
+ postLatestRelease?: ({ newVersion, dryRun, }: {
16
+ newVersion: string;
17
+ dryRun: boolean;
18
+ }) => Promise<void> | void;
16
19
  repositoryUrl: string;
17
20
  mainBranch?: string;
18
21
  }
@@ -2,6 +2,7 @@ export declare const logger: {
2
2
  log(...args: unknown[]): void;
3
3
  info(...args: unknown[]): void;
4
4
  success(...args: unknown[]): void;
5
+ warn(...args: unknown[]): void;
5
6
  error(...args: unknown[]): void;
6
7
  table(...args: unknown[]): void;
7
8
  };
@@ -9,6 +9,9 @@ export const logger = {
9
9
  success(...args) {
10
10
  console.log(`${chalk.cyan('[SUCCESS]')}`, ...args);
11
11
  },
12
+ warn(...args) {
13
+ console.log(`${chalk.yellow('[WARN]')}`, ...args);
14
+ },
12
15
  error(...args) {
13
16
  console.log(`${chalk.red('[ERROR]')}`, ...args);
14
17
  },