@elliemae/pui-cli 6.5.5 → 6.7.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.
@@ -0,0 +1,53 @@
1
+ const { exit } = require('yargs');
2
+ const { exec, logError } = require('./utils');
3
+ const { setWorkspaceVersion } = require('../monorepo/set-workspace-version');
4
+ const { setRegistryVersion } = require('../monorepo/set-registry-version');
5
+ const { deleteMergedTags } = require('../monorepo/delete-merged-tags');
6
+
7
+ const version = async (lernaOptions = '') => {
8
+ await exec(
9
+ `cross-env NODE_ENV=production lerna version --conventional-commits --exact --create-release github --force-publish --yes ${lernaOptions}`,
10
+ );
11
+ };
12
+
13
+ async function handler(argv) {
14
+ try {
15
+ if (argv.deleteTags) {
16
+ await deleteMergedTags();
17
+ } else if (argv.useRegistry) {
18
+ await setRegistryVersion();
19
+ } else if (argv.useWorkspace) {
20
+ await setWorkspaceVersion();
21
+ } else {
22
+ await version(argv.lernaOptions);
23
+ }
24
+ } catch (err) {
25
+ logError('Monorepo versioning failed', err);
26
+ exit(-1, err);
27
+ }
28
+ }
29
+
30
+ exports.command = 'version [options]';
31
+
32
+ exports.describe = 'version monorepo';
33
+
34
+ exports.builder = {
35
+ deleteTags: {
36
+ type: 'boolean',
37
+ default: false,
38
+ },
39
+ useRegistry: {
40
+ type: 'boolean',
41
+ default: false,
42
+ },
43
+ useWorkspace: {
44
+ type: 'boolean',
45
+ default: false,
46
+ },
47
+ lernaOptions: {
48
+ type: 'string',
49
+ default: false,
50
+ },
51
+ };
52
+
53
+ exports.handler = handler;
package/lib/cli.js CHANGED
@@ -13,6 +13,7 @@ const gendocCmd = require('./cli-commands/gendoc');
13
13
  const codemodCmd = require('./cli-commands/codemod');
14
14
  const storybookCmd = require('./cli-commands/storybook');
15
15
  const vitestCmd = require('./cli-commands/vitest');
16
+ const versionCmd = require('./cli-commands/version');
16
17
 
17
18
  envConfig();
18
19
  process.env.PATH +=
@@ -27,5 +28,6 @@ yargs.command(gendocCmd).help().argv;
27
28
  yargs.command(codemodCmd).help().argv;
28
29
  yargs.command(storybookCmd).help().argv;
29
30
  yargs.command(vitestCmd).help().argv;
31
+ yargs.command(versionCmd).help().argv;
30
32
 
31
33
  notifyUpdates();
@@ -0,0 +1,48 @@
1
+ const { execSync } = require('child_process');
2
+ const cwd = process.cwd();
3
+ const execaOptions = { cwd, stdio: 'inherit' };
4
+
5
+ const semVerRegEx =
6
+ /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
7
+
8
+ const isSemVersion = (tagName) => semVerRegEx.test(tagName);
9
+ const branchName = (process.env.BRANCH_NAME || 'master').toLowerCase();
10
+
11
+ const branchTags = {
12
+ master: /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,
13
+ next: /^v.*-next\.(0|[1-9]\d*)/,
14
+ alpha: /^v.*-alpha\.(0|[1-9]\d*)/,
15
+ beta: /^v.*-beta\.(0|[1-9]\d*)/,
16
+ };
17
+
18
+ const deleteTags = (cmd, filter) => {
19
+ const result = execSync(cmd, { cwd });
20
+ if (!result) return;
21
+ const tags = result.toString().split('\n').join(' ');
22
+ execSync(`git tag -d ${filter ? filter(tags) : tags}`, { cwd });
23
+ };
24
+
25
+ const tagsFromOtherBranches = (tags = []) => {
26
+ const regex = branchTags[branchName] || branchTags.master;
27
+ return tags
28
+ .split(' ')
29
+ .filter((tagName) => isSemVersion(tagName) && !regex.test(tagName))
30
+ .join(' ');
31
+ };
32
+
33
+ exports.deleteMergedTags = () => {
34
+ try {
35
+ // get tag names
36
+ if (branchName) {
37
+ // delete all tags that are not reachable from the current branch
38
+ deleteTags(`git tag -l --no-merged ${branchName}`);
39
+ // delete all tags that were not created in current branch
40
+ deleteTags(`git tag -l --merged ${branchName}`, tagsFromOtherBranches);
41
+ console.log('Last two tags: ');
42
+ execSync('git tag --sort=-creatordate | head -n 2', execaOptions);
43
+ }
44
+ } catch (error) {
45
+ // eslint-disable-next-line no-console
46
+ console.error(error);
47
+ }
48
+ };
@@ -0,0 +1,22 @@
1
+ const fg = require('fast-glob');
2
+ const { readFile, writeFile } = require('fs/promises');
3
+ const normalizePath = require('normalize-path');
4
+ const { findMonoRepoRoot } = require('./utils');
5
+
6
+ const monorepoRoot = normalizePath(findMonoRepoRoot() || '');
7
+
8
+ exports.setRegistryVersion = async () => {
9
+ const files = await fg([
10
+ `${monorepoRoot}/libs/*/package.json`,
11
+ `${monorepoRoot}/apps/*/package.json`,
12
+ `${monorepoRoot}/package.json`,
13
+ ]);
14
+ Promise.all(
15
+ files.map(async (file) => {
16
+ let pkgJSONData = await readFile(file, 'utf8');
17
+ const pkgVersion = JSON.parse(pkgJSONData).version;
18
+ pkgJSONData = pkgJSONData.replace(/workspace:\*/g, pkgVersion);
19
+ await writeFile(file, pkgJSONData);
20
+ }),
21
+ );
22
+ };
@@ -0,0 +1,29 @@
1
+ const fg = require('fast-glob');
2
+ const { readFile, writeFile } = require('fs/promises');
3
+ const normalizePath = require('normalize-path');
4
+ const { findMonoRepoRoot } = require('./utils');
5
+
6
+ const monorepoRoot = normalizePath(findMonoRepoRoot() || '');
7
+
8
+ exports.setWorkspaceVersion = async () => {
9
+ const files = await fg([
10
+ `${monorepoRoot}/libs/*/package.json`,
11
+ `${monorepoRoot}/apps/*/package.json`,
12
+ `${monorepoRoot}/package.json`,
13
+ ]);
14
+ Promise.all(
15
+ files.map(async (file) => {
16
+ let pkgJSONData = await readFile(file, 'utf8');
17
+ const pkgVersion = JSON.parse(pkgJSONData).version;
18
+ pkgJSONData = pkgJSONData.replace(
19
+ new RegExp(pkgVersion, 'g'),
20
+ 'workspace:*',
21
+ );
22
+ pkgJSONData = pkgJSONData.replace(
23
+ /"version": "workspace:\*"/g,
24
+ `"version": "${pkgVersion}"`,
25
+ );
26
+ await writeFile(file, pkgJSONData);
27
+ }),
28
+ );
29
+ };
@@ -4,7 +4,7 @@ const { sync: findUp } = require('find-up');
4
4
  const WORKSPACE_DIR_ENV_VAR = 'NPM_CONFIG_WORKSPACE_DIR';
5
5
  const WORKSPACE_MANIFEST_FILENAME = 'pnpm-workspace.yaml';
6
6
 
7
- exports.findPnpmWorkspaceDir = (cwd) => {
7
+ exports.findMonoRepoRoot = (cwd = process.cwd()) => {
8
8
  const workspaceManifestDirEnvVar =
9
9
  process.env[WORKSPACE_DIR_ENV_VAR] ??
10
10
  process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
@@ -2,7 +2,7 @@ const path = require('path');
2
2
  const normalizePath = require('normalize-path');
3
3
  const { getAppConfig, getAssetPath } = require('../webpack/helpers');
4
4
  const swcrcConfig = require('../transpile/swcrc.config.js');
5
- const { findPnpmWorkspaceDir } = require('../monorepo/utils');
5
+ const { findMonoRepoRoot } = require('../monorepo/utils');
6
6
 
7
7
  let isReactModule = true;
8
8
  try {
@@ -18,7 +18,7 @@ const getMockFilePath = (fileName) =>
18
18
  normalizePath(path.resolve(__dirname, './mocks', fileName));
19
19
 
20
20
  const getNodeModulesPath = (fileName) => {
21
- const monorepoRoot = findPnpmWorkspaceDir(process.cwd());
21
+ const monorepoRoot = findMonoRepoRoot(process.cwd());
22
22
  return normalizePath(
23
23
  monorepoRoot
24
24
  ? path.join(monorepoRoot, 'node_modules', fileName)
@@ -4,7 +4,7 @@ const fs = require('fs');
4
4
  const _ = require('lodash');
5
5
  const CompressionPlugin = require('compression-webpack-plugin');
6
6
  const zlib = require('zlib');
7
- const { findPnpmWorkspaceDir } = require('../monorepo/utils');
7
+ const { findMonoRepoRoot } = require('../monorepo/utils');
8
8
 
9
9
  let pathSep = path.sep;
10
10
  if (pathSep === '\\')
@@ -68,7 +68,7 @@ const mapToFolder = (dependencies, folder) =>
68
68
  );
69
69
 
70
70
  const getAlias = () => {
71
- const monorepoRoot = findPnpmWorkspaceDir(process.cwd()) || '';
71
+ const monorepoRoot = findMonoRepoRoot(process.cwd()) || '';
72
72
  return mapToFolder(
73
73
  [
74
74
  '@babel/runtime',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.5.5",
3
+ "version": "6.7.0",
4
4
  "private": false,
5
5
  "description": "ICE MT UI Platform CLI",
6
6
  "sideEffects": false,
@@ -63,10 +63,13 @@
63
63
  "@babel/preset-react": "~7.16.7",
64
64
  "@babel/preset-typescript": "~7.16.7",
65
65
  "@babel/runtime": "~7.17.2",
66
- "@commitlint/cli": "~16.1.0",
67
- "@commitlint/config-conventional": "~16.0.0",
66
+ "@commitlint/cli": "~16.2.1",
67
+ "@commitlint/config-conventional": "~16.2.1",
68
68
  "@elliemae/browserslist-config-elliemae-latest-browsers": "~1.3.0",
69
69
  "@faker-js/faker": "6.0.0-alpha.6",
70
+ "@nrwl/cli": "13.8.1",
71
+ "@nrwl/tao": "13.8.1",
72
+ "@nrwl/workspace": "13.8.1",
70
73
  "@pmmmwh/react-refresh-webpack-plugin": "~0.5.4",
71
74
  "@semantic-release/changelog": "~6.0.1",
72
75
  "@semantic-release/exec": "~6.0.3",
@@ -90,11 +93,11 @@
90
93
  "@testing-library/react": "~12.1.2",
91
94
  "@testing-library/react-hooks": "~7.0.2",
92
95
  "@types/jest": "~27.4.0",
93
- "@types/node": "~17.0.17",
96
+ "@types/node": "~17.0.18",
94
97
  "@types/rimraf": "~3.0.2",
95
98
  "@types/testing-library__jest-dom": "~5.14.2",
96
- "@typescript-eslint/eslint-plugin": "~5.11.0",
97
- "@typescript-eslint/parser": "~5.11.0",
99
+ "@typescript-eslint/eslint-plugin": "~5.12.0",
100
+ "@typescript-eslint/parser": "~5.12.0",
98
101
  "autoprefixer": "~10.4.2",
99
102
  "axe-core": "~4.4.1",
100
103
  "babel-loader": "~8.2.3",
@@ -161,6 +164,7 @@
161
164
  "express-static-gzip": "~2.1.4",
162
165
  "favicons": "~6.2.2",
163
166
  "favicons-webpack-plugin": "~5.0.2",
167
+ "fast-glob": "~3.2.11",
164
168
  "find-up": "~5.0.0",
165
169
  "happy-dom": "~2.31.1",
166
170
  "helmet-csp": "~3.4.0",
@@ -176,7 +180,8 @@
176
180
  "jest-styled-components": "~7.0.8",
177
181
  "jscodeshift": "~0.13.1",
178
182
  "jsdoc": "~3.6.10",
179
- "lint-staged": "~12.3.3",
183
+ "lerna": "~4.0.0",
184
+ "lint-staged": "~12.3.4",
180
185
  "mini-css-extract-plugin": "~2.5.3",
181
186
  "minimist": "~1.2.5",
182
187
  "moment": "~2.29.1",
@@ -197,7 +202,7 @@
197
202
  "postcss-jsx": "~0.36.4",
198
203
  "postcss-loader": "~6.2.1",
199
204
  "postcss-markdown": "~1.2.0",
200
- "postcss-preset-env": "~7.3.2",
205
+ "postcss-preset-env": "~7.3.3",
201
206
  "postcss-syntax": "~0.36.2",
202
207
  "prettier": "~2.5.1",
203
208
  "pug": "~3.0.2",
@@ -228,8 +233,8 @@
228
233
  "update-notifier": "~5.1.0",
229
234
  "url-loader": "~4.1.1",
230
235
  "uuid": "~8.3.2",
231
- "vite": "~2.8.1",
232
- "vitest": "~0.3.4",
236
+ "vite": "~2.8.2",
237
+ "vitest": "~0.3.5",
233
238
  "webpack": "~5.65.0",
234
239
  "webpack-bundle-analyzer": "~4.5.0",
235
240
  "webpack-cli": "~4.9.2",