@elliemae/pui-cli 6.0.0-beta.31 → 6.0.0-beta.35

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,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,66 @@
1
+ const execa = require('execa');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const { randomChars, resolveFromRoot } = require('./utils');
6
+
7
+ const args = process.argv.slice(2);
8
+ const argsProjectIndex = args.findIndex((arg) =>
9
+ ['-p', '--project'].includes(arg),
10
+ );
11
+ const argsProjectValue =
12
+ argsProjectIndex !== -1 ? args[argsProjectIndex + 1] : undefined;
13
+
14
+ const files = args.filter((file) => /\.(ts|tsx)$/.test(file));
15
+ if (files.length === 0) {
16
+ process.exit(0);
17
+ }
18
+
19
+ const remainingArgsToForward = args
20
+ .slice()
21
+ .filter((arg) => !files.includes(arg));
22
+
23
+ if (argsProjectIndex !== -1) {
24
+ remainingArgsToForward.splice(argsProjectIndex, 2);
25
+ }
26
+
27
+ // Load existing config
28
+ const tsconfigPath = argsProjectValue || resolveFromRoot('tsconfig.json');
29
+ const tsconfigContent = fs.readFileSync(tsconfigPath).toString();
30
+ // Use 'eval' to read the JSON as regular JavaScript syntax so that comments are allowed
31
+ // eslint-disable-next-line prefer-const
32
+ let tsconfig = {};
33
+ // eslint-disable-next-line no-eval
34
+ eval(`tsconfig = ${tsconfigContent}`);
35
+
36
+ // Write a temp config file
37
+ const tmpTsconfigPath = resolveFromRoot(`tsconfig.${randomChars()}.json`);
38
+ const tmpTsconfig = {
39
+ ...tsconfig,
40
+ compilerOptions: {
41
+ ...tsconfig.compilerOptions,
42
+ skipLibCheck: true,
43
+ },
44
+ files,
45
+ include: ['app', 'lib'],
46
+ };
47
+ fs.writeFileSync(tmpTsconfigPath, JSON.stringify(tmpTsconfig, null, 2));
48
+
49
+ // Type-check our files
50
+ let status = 0;
51
+ try {
52
+ execa.sync(
53
+ path.resolve(
54
+ process.cwd(),
55
+ `./node_modules/.bin/tsc${process.platform === 'win32' ? '.cmd' : ''}`,
56
+ ),
57
+ ['-p', tmpTsconfigPath, ...remainingArgsToForward],
58
+ { stdio: 'inherit' },
59
+ );
60
+ } catch (ex) {
61
+ status = ex.exitCode;
62
+ }
63
+
64
+ // Delete temp config file
65
+ fs.unlinkSync(tmpTsconfigPath);
66
+ 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.31",
3
+ "version": "6.0.0-beta.35",
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,17 +83,17 @@
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.126",
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.6",
92
+ "@types/node": "~17.0.7",
93
93
  "@types/rimraf": "~3.0.2",
94
94
  "@types/testing-library__jest-dom": "~5.14.2",
95
- "@typescript-eslint/eslint-plugin": "~5.8.1",
96
- "@typescript-eslint/parser": "~5.8.1",
95
+ "@typescript-eslint/eslint-plugin": "~5.9.0",
96
+ "@typescript-eslint/parser": "~5.9.0",
97
97
  "autoprefixer": "~10.4.1",
98
98
  "axe-core": "~4.3.5",
99
99
  "babel-loader": "~8.2.3",
@@ -134,19 +134,19 @@
134
134
  "esbuild-loader": "~2.18.0",
135
135
  "esbuild-plugin-svgr": "~1.0.0",
136
136
  "eslint": "~8.6.0",
137
- "eslint-config-airbnb": "~18.2.1",
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",
149
- "eslint-plugin-jsdoc": "~37.5.0",
147
+ "eslint-plugin-import": "~2.25.4",
148
+ "eslint-plugin-jest": "~25.3.4",
149
+ "eslint-plugin-jsdoc": "~37.5.1",
150
150
  "eslint-plugin-jsx-a11y": "~6.5.1",
151
151
  "eslint-plugin-mdx": "~1.16.0",
152
152
  "eslint-plugin-prettier": "~4.0.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",