@elliemae/pui-cli 6.0.0-beta.30 → 6.0.0-beta.34

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.
@@ -4,9 +4,7 @@ const { exec, logError, logSuccess } = require('./utils');
4
4
  const { CI = false } = process.env;
5
5
 
6
6
  async function test(commandOptions) {
7
- await exec(
8
- `cross-env FORCE_COLOR=true NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest ${commandOptions}`,
9
- );
7
+ await exec(`cross-env FORCE_COLOR=true NODE_ENV=test jest ${commandOptions}`);
10
8
  }
11
9
 
12
10
  // eslint-disable-next-line max-statements
@@ -0,0 +1,103 @@
1
+ const { exit } = require('yargs');
2
+ const { dirname, join } = require('path');
3
+ const { spawnSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const { logInfo, logError } = require('./utils');
6
+
7
+ const randomChars = () => Math.random().toString(36).slice(2);
8
+
9
+ const resolveFromModule = (moduleName, ...paths) => {
10
+ const modulePath = dirname(require.resolve(`${moduleName}/package.json`));
11
+ return join(modulePath, ...paths);
12
+ };
13
+
14
+ const resolveFromRoot = (...paths) => join(process.cwd(), ...paths);
15
+
16
+ const validateTypescript = async () => {
17
+ const args = process.argv.slice(2);
18
+ const argsProjectIndex = args.findIndex((arg) =>
19
+ ['-p', '--project'].includes(arg),
20
+ );
21
+ const argsProjectValue =
22
+ argsProjectIndex !== -1 ? args[argsProjectIndex + 1] : undefined;
23
+
24
+ const files = args.filter((file) => /\.(ts|tsx)$/.test(file));
25
+ if (files.length === 0) {
26
+ process.exit(0);
27
+ }
28
+
29
+ const remainingArgsToForward = args
30
+ .slice()
31
+ .filter((arg) => !files.includes(arg));
32
+
33
+ if (argsProjectIndex !== -1) {
34
+ remainingArgsToForward.splice(argsProjectIndex, 2);
35
+ }
36
+
37
+ // Load existing config
38
+ const tsconfigPath = argsProjectValue || resolveFromRoot('tsconfig.json');
39
+ const tsconfigContent = fs.readFileSync(tsconfigPath).toString();
40
+ // Use 'eval' to read the JSON as regular JavaScript syntax so that comments are allowed
41
+ // eslint-disable-next-line prefer-const
42
+ let tsconfig = {};
43
+ // eslint-disable-next-line no-eval
44
+ eval(`tsconfig = ${tsconfigContent}`);
45
+
46
+ // Write a temp config file
47
+ const tmpTsconfigPath = resolveFromRoot(`tsconfig.${randomChars()}.json`);
48
+ const tmpTsconfig = {
49
+ ...tsconfig,
50
+ compilerOptions: {
51
+ ...tsconfig.compilerOptions,
52
+ skipLibCheck: true,
53
+ },
54
+ files,
55
+ include: ['shared/typings'],
56
+ };
57
+ fs.writeFileSync(tmpTsconfigPath, JSON.stringify(tmpTsconfig, null, 2));
58
+
59
+ // Type-check our files
60
+ const { status } = spawnSync(
61
+ resolveFromModule(
62
+ 'typescript',
63
+ `../.bin/tsc${process.platform === 'win32' ? '.cmd' : ''}`,
64
+ ),
65
+ ['-p', tmpTsconfigPath, ...remainingArgsToForward],
66
+ { stdio: 'inherit' },
67
+ );
68
+
69
+ // Delete temp config file
70
+ fs.unlinkSync(tmpTsconfigPath);
71
+
72
+ process.exit(status);
73
+ };
74
+
75
+ async function handler(argv) {
76
+ try {
77
+ await validateTypescript(argv.p);
78
+ logInfo('Typescript validation started');
79
+ } catch (err) {
80
+ logError('Typescript validation failed', err);
81
+ exit(-1, err);
82
+ }
83
+ }
84
+
85
+ exports.command = 'tsc [options]';
86
+
87
+ exports.describe = 'validate typescript code';
88
+
89
+ exports.builder = {
90
+ project: {
91
+ alias: 'p',
92
+ type: 'boolean',
93
+ default: false,
94
+ },
95
+ docs: {
96
+ type: 'boolean',
97
+ default: false,
98
+ },
99
+ };
100
+
101
+ exports.handler = handler;
102
+
103
+ exports.validateTypescript = validateTypescript;
@@ -105,6 +105,10 @@ const reactRules = {
105
105
  1,
106
106
  { extensions: ['.js', '.jsx', '.tsx', '.mdx'] },
107
107
  ],
108
+ 'react/function-component-definition': [
109
+ 2,
110
+ { namedComponents: 'arrow-function' },
111
+ ],
108
112
  'redux-saga/no-yield-in-race': 2,
109
113
  'redux-saga/yield-effects': 2,
110
114
  };
@@ -1,5 +1,12 @@
1
+ const path = require('path');
2
+
1
3
  module.exports = {
2
- '*.{ts,tsx}': ['tsc-files --noEmit --emitDeclarationOnly false'],
4
+ '*.{ts,tsx}': [
5
+ `node ${path.resolve(
6
+ __dirname,
7
+ '../typescript/tsc-files/index.js',
8
+ )} --noEmit --emitDeclarationOnly false`,
9
+ ],
3
10
  '*.{js,ts,jsx,tsx}': [
4
11
  'npm run lint:fix',
5
12
  'npm run test:staged',
@@ -95,7 +95,7 @@ const jestConfig = {
95
95
  // ],
96
96
  // },
97
97
  transformIgnorePatterns: [
98
- 'node_modules/(?!(@elliemae/pui-cli|lodash-es|react-select|react-dates)/)',
98
+ 'node_modules/(?!(.*@elliemae/pui-cli|lodash-es|react-select|react-dates)/)',
99
99
  ],
100
100
  globals: {
101
101
  APP_CONFIG: getAppConfig(),
@@ -0,0 +1,61 @@
1
+ const { spawnSync } = require('child_process');
2
+ const fs = require('fs');
3
+
4
+ const { randomChars, resolveFromModule, resolveFromRoot } = require('./utils');
5
+
6
+ const args = process.argv.slice(2);
7
+ const argsProjectIndex = args.findIndex((arg) =>
8
+ ['-p', '--project'].includes(arg),
9
+ );
10
+ const argsProjectValue =
11
+ argsProjectIndex !== -1 ? args[argsProjectIndex + 1] : undefined;
12
+
13
+ const files = args.filter((file) => /\.(ts|tsx)$/.test(file));
14
+ if (files.length === 0) {
15
+ process.exit(0);
16
+ }
17
+
18
+ const remainingArgsToForward = args
19
+ .slice()
20
+ .filter((arg) => !files.includes(arg));
21
+
22
+ if (argsProjectIndex !== -1) {
23
+ remainingArgsToForward.splice(argsProjectIndex, 2);
24
+ }
25
+
26
+ // Load existing config
27
+ const tsconfigPath = argsProjectValue || resolveFromRoot('tsconfig.json');
28
+ const tsconfigContent = fs.readFileSync(tsconfigPath).toString();
29
+ // Use 'eval' to read the JSON as regular JavaScript syntax so that comments are allowed
30
+ // eslint-disable-next-line prefer-const
31
+ let tsconfig = {};
32
+ // eslint-disable-next-line no-eval
33
+ eval(`tsconfig = ${tsconfigContent}`);
34
+
35
+ // Write a temp config file
36
+ const tmpTsconfigPath = resolveFromRoot(`tsconfig.${randomChars()}.json`);
37
+ const tmpTsconfig = {
38
+ ...tsconfig,
39
+ compilerOptions: {
40
+ ...tsconfig.compilerOptions,
41
+ skipLibCheck: true,
42
+ },
43
+ files,
44
+ include: ['app', 'lib'],
45
+ };
46
+ fs.writeFileSync(tmpTsconfigPath, JSON.stringify(tmpTsconfig, null, 2));
47
+
48
+ // Type-check our files
49
+ const { status } = spawnSync(
50
+ resolveFromModule(
51
+ 'typescript',
52
+ `../.bin/tsc${process.platform === 'win32' ? '.cmd' : ''}`,
53
+ ),
54
+ ['-p', tmpTsconfigPath, ...remainingArgsToForward],
55
+ { stdio: 'inherit' },
56
+ );
57
+
58
+ // Delete temp config file
59
+ fs.unlinkSync(tmpTsconfigPath);
60
+
61
+ process.exit(status);
@@ -0,0 +1,16 @@
1
+ const { dirname, join } = require('path');
2
+
3
+ const randomChars = () => Math.random().toString(36).slice(2);
4
+
5
+ const resolveFromModule = (moduleName, ...paths) => {
6
+ const modulePath = dirname(require.resolve(`${moduleName}/package.json`));
7
+ return join(modulePath, ...paths);
8
+ };
9
+
10
+ const resolveFromRoot = (...paths) => join(process.cwd(), ...paths);
11
+
12
+ module.exports = {
13
+ randomChars,
14
+ resolveFromModule,
15
+ resolveFromRoot,
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.0.0-beta.30",
3
+ "version": "6.0.0-beta.34",
4
4
  "private": false,
5
5
  "description": "ICE MT UI Platform CLI",
6
6
  "sideEffects": false,
@@ -34,7 +34,7 @@
34
34
  "release": "semantic-release",
35
35
  "test": "ts-node -r tsconfig-paths/register ./lib/cli test -p",
36
36
  "test:staged": "jest --coverage --passWithNoTests --bail --findRelatedTests",
37
- "setup": "rimraf -r node_modules && rimraf package-lock.json && npm i",
37
+ "setup": "rimraf -r node_modules && rimraf pnpm-lock.yaml && pnpm i",
38
38
  "storybook:build": "exit 0",
39
39
  "storybook:docs:build": "exit 0",
40
40
  "upgrade": "ncu -u && npm run setup",
@@ -83,13 +83,13 @@
83
83
  "@stylelint/postcss-css-in-js": "~0.37.2",
84
84
  "@svgr/webpack": "~6.1.2",
85
85
  "@swc/cli": "~0.1.55",
86
- "@swc/core": "~1.2.124",
86
+ "@swc/core": "~1.2.125",
87
87
  "@swc/jest": "~0.2.15",
88
88
  "@testing-library/jest-dom": "~5.16.1",
89
89
  "@testing-library/react": "~12.1.2",
90
90
  "@testing-library/react-hooks": "~7.0.2",
91
91
  "@types/jest": "~27.4.0",
92
- "@types/node": "~17.0.5",
92
+ "@types/node": "~17.0.6",
93
93
  "@types/rimraf": "~3.0.2",
94
94
  "@types/testing-library__jest-dom": "~5.14.2",
95
95
  "@typescript-eslint/eslint-plugin": "~5.8.1",
@@ -129,23 +129,23 @@
129
129
  "dotenv-webpack": "~7.0.3",
130
130
  "duplicate-package-checker-webpack-plugin": "~3.0.0",
131
131
  "enhanced-resolve": "~5.8.3",
132
- "esbuild": "~0.14.9",
132
+ "esbuild": "~0.14.10",
133
133
  "esbuild-jest": "~0.5.0",
134
134
  "esbuild-loader": "~2.18.0",
135
135
  "esbuild-plugin-svgr": "~1.0.0",
136
- "eslint": "~8.5.0",
137
- "eslint-config-airbnb": "~18.2.1",
136
+ "eslint": "~8.6.0",
137
+ "eslint-config-airbnb": "~19.0.4",
138
138
  "eslint-config-airbnb-base": "~15.0.0",
139
- "eslint-config-airbnb-typescript": "~15.0.0",
139
+ "eslint-config-airbnb-typescript": "~16.1.0",
140
140
  "eslint-config-prettier": "~8.3.0",
141
- "eslint-config-react-app": "~6.0.0",
141
+ "eslint-config-react-app": "~7.0.0",
142
142
  "eslint-import-resolver-babel-module": "~5.3.1",
143
143
  "eslint-import-resolver-typescript": "~2.5.0",
144
144
  "eslint-import-resolver-webpack": "~0.13.2",
145
- "eslint-plugin-compat": "~3.13.0",
145
+ "eslint-plugin-compat": "~4.0.0",
146
146
  "eslint-plugin-eslint-comments": "~3.2.0",
147
- "eslint-plugin-import": "~2.25.3",
148
- "eslint-plugin-jest": "~25.3.3",
147
+ "eslint-plugin-import": "~2.25.4",
148
+ "eslint-plugin-jest": "~25.3.4",
149
149
  "eslint-plugin-jsdoc": "~37.5.0",
150
150
  "eslint-plugin-jsx-a11y": "~6.5.1",
151
151
  "eslint-plugin-mdx": "~1.16.0",
@@ -178,7 +178,7 @@
178
178
  "jest-styled-components": "~7.0.8",
179
179
  "jscodeshift": "~0.13.0",
180
180
  "jsdoc": "~3.6.7",
181
- "lint-staged": "~12.1.4",
181
+ "lint-staged": "~12.1.5",
182
182
  "mini-css-extract-plugin": "~2.4.5",
183
183
  "minimist": "~1.2.5",
184
184
  "moment": "~2.29.1",
@@ -187,7 +187,7 @@
187
187
  "node-gyp": "~8.4.1",
188
188
  "node-plop": "~0.30.0",
189
189
  "nodemon": "~2.0.15",
190
- "npm-check-updates": "12.0.5",
190
+ "npm-check-updates": "12.1.0",
191
191
  "null-loader": "~4.0.1",
192
192
  "pino": "~7.6.2",
193
193
  "pino-pretty": "~7.3.0",
@@ -199,7 +199,7 @@
199
199
  "postcss-markdown": "~1.2.0",
200
200
  "postcss-syntax": "~0.36.2",
201
201
  "postcss-loader": "~6.2.1",
202
- "postcss-preset-env": "~7.1.0",
202
+ "postcss-preset-env": "~7.2.0",
203
203
  "prettier": "~2.5.1",
204
204
  "pug": "~3.0.2",
205
205
  "pug-loader": "~2.4.0",