@elliemae/pui-cli 7.0.0-beta.9 → 7.2.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/README.md +4 -0
- package/{lib/babel/babel.config.js → dist/cjs/babel.config.cjs} +3 -7
- package/dist/cjs/cli.js +53 -0
- package/dist/cjs/commands/build.js +81 -0
- package/dist/cjs/commands/codemod.js +55 -0
- package/dist/cjs/commands/gendoc.js +53 -0
- package/dist/cjs/commands/lint.js +95 -0
- package/dist/cjs/commands/pack.js +98 -0
- package/dist/cjs/commands/start.js +76 -0
- package/dist/cjs/commands/storybook.js +71 -0
- package/dist/cjs/commands/test.js +100 -0
- package/dist/cjs/commands/tscheck.js +82 -0
- package/dist/cjs/commands/utils.js +157 -0
- package/dist/cjs/commands/version.js +77 -0
- package/dist/cjs/commands/vitest.js +93 -0
- package/dist/cjs/dummy.js +1 -0
- package/dist/cjs/index.cjs +25 -0
- package/dist/cjs/index.js +42 -0
- package/dist/cjs/jsdoc.conf.json +17 -0
- package/dist/cjs/lint-config/commitlint.config.cjs +1 -0
- package/{lib/lint/eslint/common.js → dist/cjs/lint-config/eslint/common.cjs} +5 -5
- package/{lib/lint/eslint/non-react.js → dist/cjs/lint-config/eslint/non-react.cjs} +2 -2
- package/{lib/lint/eslint/react.js → dist/cjs/lint-config/eslint/react.cjs} +2 -2
- package/{lib/lint/eslint/typescript/common.js → dist/cjs/lint-config/eslint/typescript/common.cjs} +1 -1
- package/{lib/lint/eslint/typescript/non-react.js → dist/cjs/lint-config/eslint/typescript/non-react.cjs} +2 -2
- package/{lib/lint/eslint/typescript/react.js → dist/cjs/lint-config/eslint/typescript/react.cjs} +2 -2
- package/dist/cjs/lint-config/lint-staged.config.js +40 -0
- package/{lib/lint/prettier.config.js → dist/cjs/lint-config/prettier.config.cjs} +1 -1
- package/{lib/lint/stylelint.config.js → dist/cjs/lint-config/stylelint.config.cjs} +2 -2
- package/dist/cjs/monorepo/delete-merged-tags.js +58 -0
- package/dist/cjs/monorepo/set-registry-version.js +49 -0
- package/dist/cjs/monorepo/set-workspace-version.js +56 -0
- package/{lib/monorepo/utils.js → dist/cjs/monorepo/utils.cjs} +17 -2
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/pui-config.js +44 -0
- package/{lib/release/release.config.js → dist/cjs/release.config.cjs} +0 -0
- package/{lib/server/util/index.js → dist/cjs/server/app-routes.cjs} +5 -15
- package/dist/cjs/server/csp.js +94 -0
- package/dist/cjs/server/index.js +34 -0
- package/dist/cjs/server/logger.js +58 -0
- package/dist/cjs/server/middlewares.js +75 -0
- package/dist/cjs/server/utils.js +39 -0
- package/{lib/testing/jest.config.js → dist/cjs/testing/jest.config.cjs} +10 -10
- package/{lib/testing/jest.node.config.js → dist/cjs/testing/jest.node.config.cjs} +1 -1
- package/dist/cjs/testing/mocks/axios.js +38 -0
- package/dist/cjs/testing/mocks/cssModule.js +24 -0
- package/dist/cjs/testing/mocks/html.js +24 -0
- package/dist/cjs/testing/mocks/image.js +24 -0
- package/dist/cjs/testing/mocks/matchMedia.js +44 -0
- package/dist/cjs/testing/mocks/pui-app-loader.js +25 -0
- package/dist/cjs/testing/mocks/pui-diagnostics.js +69 -0
- package/dist/cjs/testing/mocks/pui-user-monitoring.js +31 -0
- package/dist/cjs/testing/mocks/retry-axios.js +28 -0
- package/dist/cjs/testing/mocks/svg.js +33 -0
- package/dist/cjs/testing/mocks/webpack-hmr.js +25 -0
- package/{lib/testing/resolver.js → dist/cjs/testing/resolver.cjs} +0 -0
- package/dist/cjs/testing/setup-react-env.js +22 -0
- package/dist/cjs/testing/setup-test-env.js +23 -0
- package/dist/cjs/testing/setup-tests.js +69 -0
- package/dist/cjs/testing/vitest.config.js +52 -0
- package/{lib → dist/cjs}/transpile/.swcrc +0 -0
- package/dist/cjs/transpile/esbuild.js +134 -0
- package/dist/cjs/transpile/react-shim.js +30 -0
- package/{lib/transpile/swcrc.config.js → dist/cjs/transpile/swcrc.config.cjs} +1 -1
- package/dist/cjs/typedoc.cjs +12 -0
- package/{lib → dist/cjs}/typescript/app.tsconfig.json +0 -0
- package/{lib → dist/cjs}/typescript/library.tsconfig.json +0 -0
- package/dist/cjs/update-notifier.js +37 -0
- package/dist/cjs/utils.cjs +23 -0
- package/dist/cjs/webpack/helpers.js +237 -0
- package/dist/cjs/webpack/webpack.base.babel.js +280 -0
- package/dist/cjs/webpack/webpack.dev.babel.js +144 -0
- package/dist/cjs/webpack/webpack.lib.base.babel.js +212 -0
- package/dist/cjs/webpack/webpack.lib.dev.babel.js +93 -0
- package/dist/cjs/webpack/webpack.lib.prod.babel.js +95 -0
- package/dist/cjs/webpack/webpack.prod.babel.js +145 -0
- package/dist/cjs/webpack/webpack.storybook.js +111 -0
- package/dist/esm/babel.config.cjs +97 -0
- package/dist/esm/cli.js +33 -0
- package/dist/esm/commands/build.js +61 -0
- package/dist/esm/commands/codemod.js +29 -0
- package/dist/esm/commands/gendoc.js +26 -0
- package/dist/esm/commands/lint.js +69 -0
- package/dist/esm/commands/pack.js +71 -0
- package/dist/esm/commands/start.js +49 -0
- package/dist/esm/commands/storybook.js +45 -0
- package/dist/esm/commands/test.js +74 -0
- package/dist/esm/commands/tscheck.js +56 -0
- package/dist/esm/commands/utils.js +143 -0
- package/dist/esm/commands/version.js +51 -0
- package/dist/esm/commands/vitest.js +66 -0
- package/{lib/dummy.ts → dist/esm/dummy.js} +0 -0
- package/dist/esm/index.cjs +25 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/jsdoc.conf.json +17 -0
- package/dist/esm/lint-config/commitlint.config.cjs +1 -0
- package/dist/esm/lint-config/eslint/common.cjs +160 -0
- package/dist/esm/lint-config/eslint/non-react.cjs +14 -0
- package/dist/esm/lint-config/eslint/react.cjs +26 -0
- package/dist/esm/lint-config/eslint/typescript/common.cjs +43 -0
- package/dist/esm/lint-config/eslint/typescript/non-react.cjs +12 -0
- package/dist/esm/lint-config/eslint/typescript/react.cjs +19 -0
- package/dist/esm/lint-config/lint-staged.config.js +14 -0
- package/dist/esm/lint-config/prettier.config.cjs +8 -0
- package/dist/esm/lint-config/stylelint.config.cjs +19 -0
- package/dist/esm/monorepo/delete-merged-tags.js +38 -0
- package/dist/esm/monorepo/set-registry-version.js +23 -0
- package/dist/esm/monorepo/set-workspace-version.js +30 -0
- package/dist/esm/monorepo/utils.cjs +30 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/pui-config.js +18 -0
- package/dist/esm/release.config.cjs +31 -0
- package/dist/esm/server/app-routes.cjs +42 -0
- package/dist/esm/server/csp.js +68 -0
- package/dist/esm/server/index.js +18 -0
- package/dist/esm/server/logger.js +32 -0
- package/dist/esm/server/middlewares.js +49 -0
- package/dist/esm/server/utils.js +13 -0
- package/dist/esm/testing/jest.config.cjs +103 -0
- package/dist/esm/testing/jest.node.config.cjs +8 -0
- package/{lib → dist/esm}/testing/mocks/axios.js +8 -5
- package/dist/esm/testing/mocks/cssModule.js +4 -0
- package/dist/esm/testing/mocks/html.js +4 -0
- package/dist/esm/testing/mocks/image.js +4 -0
- package/dist/esm/testing/mocks/matchMedia.js +24 -0
- package/dist/esm/testing/mocks/pui-app-loader.js +5 -0
- package/dist/esm/testing/mocks/pui-diagnostics.js +49 -0
- package/dist/esm/testing/mocks/pui-user-monitoring.js +11 -0
- package/dist/esm/testing/mocks/retry-axios.js +8 -0
- package/dist/esm/testing/mocks/svg.js +7 -0
- package/dist/esm/testing/mocks/webpack-hmr.js +5 -0
- package/dist/esm/testing/resolver.cjs +47 -0
- package/dist/esm/testing/setup-react-env.js +3 -0
- package/dist/esm/testing/setup-test-env.js +4 -0
- package/dist/esm/testing/setup-tests.js +50 -0
- package/dist/esm/testing/vitest.config.js +25 -0
- package/dist/esm/transpile/.swcrc +11 -0
- package/{lib → dist/esm}/transpile/esbuild.js +35 -44
- package/dist/esm/transpile/react-shim.js +4 -0
- package/dist/esm/transpile/swcrc.config.cjs +13 -0
- package/dist/esm/typedoc.cjs +12 -0
- package/dist/esm/typescript/app.tsconfig.json +23 -0
- package/dist/esm/typescript/library.tsconfig.json +23 -0
- package/dist/esm/update-notifier.js +11 -0
- package/dist/esm/utils.cjs +23 -0
- package/dist/esm/webpack/helpers.js +211 -0
- package/dist/esm/webpack/webpack.base.babel.js +260 -0
- package/dist/esm/webpack/webpack.dev.babel.js +121 -0
- package/dist/esm/webpack/webpack.lib.base.babel.js +192 -0
- package/dist/esm/webpack/webpack.lib.dev.babel.js +67 -0
- package/dist/esm/webpack/webpack.lib.prod.babel.js +69 -0
- package/dist/esm/webpack/webpack.prod.babel.js +124 -0
- package/dist/esm/webpack/webpack.storybook.js +85 -0
- package/dist/types/babel.config.d.cts +59 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/commands/build.d.ts +14 -0
- package/dist/types/commands/codemod.d.ts +6 -0
- package/dist/types/commands/gendoc.d.ts +6 -0
- package/dist/types/commands/lint.d.ts +29 -0
- package/dist/types/commands/pack.d.ts +26 -0
- package/dist/types/commands/start.d.ts +13 -0
- package/dist/types/commands/storybook.d.ts +19 -0
- package/dist/types/commands/test.d.ts +39 -0
- package/dist/types/commands/tscheck.d.ts +14 -0
- package/dist/types/commands/utils.d.ts +16 -0
- package/dist/types/commands/version.d.ts +30 -0
- package/dist/types/commands/vitest.d.ts +35 -0
- package/{lib/testing/vitest.setup.ts → dist/types/dummy.d.ts} +0 -0
- package/dist/types/index.d.cts +10 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/lint-config/commitlint.config.d.cts +4 -0
- package/dist/types/lint-config/eslint/common.d.cts +127 -0
- package/dist/types/lint-config/eslint/non-react.d.cts +93 -0
- package/dist/types/lint-config/eslint/react.d.cts +123 -0
- package/dist/types/lint-config/eslint/typescript/common.d.cts +37 -0
- package/dist/types/lint-config/eslint/typescript/non-react.d.cts +87 -0
- package/dist/types/lint-config/eslint/typescript/react.d.cts +118 -0
- package/dist/types/lint-config/lint-staged.config.d.ts +5 -0
- package/dist/types/lint-config/prettier.config.d.cts +8 -0
- package/dist/types/lint-config/stylelint.config.d.cts +11 -0
- package/dist/types/monorepo/delete-merged-tags.d.ts +1 -0
- package/dist/types/monorepo/set-registry-version.d.ts +1 -0
- package/dist/types/monorepo/set-workspace-version.d.ts +1 -0
- package/dist/types/monorepo/utils.d.cts +1 -0
- package/dist/types/pui-config.d.ts +1 -0
- package/dist/types/release.config.d.cts +9 -0
- package/dist/types/server/app-routes.d.cts +1 -0
- package/dist/types/server/csp.d.ts +10 -0
- package/dist/types/server/index.d.ts +1 -0
- package/dist/types/server/logger.d.ts +4 -0
- package/dist/types/server/middlewares.d.ts +2 -0
- package/dist/types/server/utils.d.ts +3 -0
- package/dist/types/testing/jest.config.d.cts +39 -0
- package/dist/types/testing/jest.node.config.d.cts +39 -0
- package/dist/types/testing/mocks/axios.d.ts +17 -0
- package/dist/types/testing/mocks/cssModule.d.ts +2 -0
- package/dist/types/testing/mocks/html.d.ts +2 -0
- package/dist/types/testing/mocks/image.d.ts +2 -0
- package/dist/types/testing/mocks/matchMedia.d.ts +1 -0
- package/dist/types/testing/mocks/pui-app-loader.d.ts +1 -0
- package/dist/types/testing/mocks/pui-diagnostics.d.ts +28 -0
- package/dist/types/testing/mocks/pui-user-monitoring.d.ts +3 -0
- package/dist/types/testing/mocks/retry-axios.d.ts +3 -0
- package/dist/types/testing/mocks/svg.d.ts +3 -0
- package/dist/types/testing/mocks/webpack-hmr.d.ts +1 -0
- package/dist/types/testing/resolver.d.cts +2 -0
- package/dist/types/testing/setup-react-env.d.ts +1 -0
- package/dist/types/testing/setup-test-env.d.ts +2 -0
- package/dist/types/testing/setup-tests.d.ts +1 -0
- package/dist/types/testing/vitest.config.d.ts +2 -0
- package/dist/types/transpile/esbuild.d.ts +13 -0
- package/dist/types/transpile/react-shim.d.ts +2 -0
- package/dist/types/transpile/swcrc.config.d.cts +1 -0
- package/dist/types/typedoc.d.cts +3 -0
- package/dist/types/update-notifier.d.ts +1 -0
- package/dist/types/utils.d.cts +4 -0
- package/dist/types/webpack/helpers.d.ts +28 -0
- package/dist/types/webpack/webpack.base.babel.d.ts +90 -0
- package/dist/types/webpack/webpack.dev.babel.d.ts +2 -0
- package/dist/types/webpack/webpack.lib.base.babel.d.ts +110 -0
- package/dist/types/webpack/webpack.lib.dev.babel.d.ts +110 -0
- package/dist/types/webpack/webpack.lib.prod.babel.d.ts +110 -0
- package/dist/types/webpack/webpack.prod.babel.d.ts +2 -0
- package/dist/types/webpack/webpack.storybook.d.ts +4 -0
- package/package.json +159 -144
- package/lib/cli-commands/build.js +0 -60
- package/lib/cli-commands/codemod.js +0 -31
- package/lib/cli-commands/gendoc.js +0 -36
- package/lib/cli-commands/lint.js +0 -75
- package/lib/cli-commands/pack.js +0 -67
- package/lib/cli-commands/start.js +0 -49
- package/lib/cli-commands/storybook.js +0 -53
- package/lib/cli-commands/test.js +0 -63
- package/lib/cli-commands/tsc.js +0 -103
- package/lib/cli-commands/utils.js +0 -135
- package/lib/cli-commands/version.js +0 -53
- package/lib/cli-commands/vitest.js +0 -66
- package/lib/cli.js +0 -33
- package/lib/docgen/jsdoc.config.js +0 -17
- package/lib/index.js +0 -25
- package/lib/lint/commitlint.config.js +0 -1
- package/lib/lint/lint-staged.config.js +0 -16
- package/lib/monorepo/delete-merged-tags.js +0 -48
- package/lib/monorepo/set-registry-version.js +0 -22
- package/lib/monorepo/set-workspace-version.js +0 -29
- package/lib/pui-config/index.js +0 -18
- package/lib/scripts/helpers/checkmark.js +0 -15
- package/lib/scripts/helpers/get-npm-config.js +0 -3
- package/lib/scripts/helpers/progress.js +0 -19
- package/lib/scripts/helpers/xmark.js +0 -13
- package/lib/scripts/npmcheckversion.js +0 -8
- package/lib/scripts/update-notifier.js +0 -7
- package/lib/server/csp.js +0 -74
- package/lib/server/index.js +0 -37
- package/lib/server/logger.js +0 -42
- package/lib/server/middlewares/addDevMiddlewares.js +0 -39
- package/lib/server/middlewares/addProdMiddlewares.js +0 -30
- package/lib/server/middlewares/index.js +0 -37
- package/lib/testing/mocks/cssModule.js +0 -1
- package/lib/testing/mocks/html.js +0 -1
- package/lib/testing/mocks/image.js +0 -1
- package/lib/testing/mocks/matchMedia.js +0 -24
- package/lib/testing/mocks/pui-app-loader.js +0 -1
- package/lib/testing/mocks/pui-diagnostics.js +0 -28
- package/lib/testing/mocks/pui-user-monitoring.js +0 -3
- package/lib/testing/mocks/retry-axios.js +0 -3
- package/lib/testing/mocks/svg.js +0 -5
- package/lib/testing/mocks/webpack-hmr.js +0 -1
- package/lib/testing/setup-react-env.js +0 -3
- package/lib/testing/setup-tests.js +0 -58
- package/lib/testing/vitest.config.ts +0 -16
- package/lib/transpile/react-shim.js +0 -2
- package/lib/typescript/tsc-files/index.js +0 -66
- package/lib/typescript/tsc-files/utils.js +0 -16
- package/lib/typescript/util.js +0 -5
- package/lib/webpack/helpers.js +0 -252
- package/lib/webpack/webpack.base.babel.js +0 -242
- package/lib/webpack/webpack.dev.babel.js +0 -139
- package/lib/webpack/webpack.lib.base.babel.js +0 -205
- package/lib/webpack/webpack.lib.dev.babel.js +0 -49
- package/lib/webpack/webpack.lib.prod.babel.js +0 -77
- package/lib/webpack/webpack.prod.babel.js +0 -142
- package/lib/webpack/webpack.storybook.js +0 -87
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports.commitlintConfig = { extends: ['@commitlint/config-conventional'] };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
const prettierOptions = require('../prettier.config.cjs');
|
|
3
|
+
// const webpackConfig = require('../../webpack/webpack.prod.babel');
|
|
4
|
+
|
|
5
|
+
exports.baseExtends = [
|
|
6
|
+
'plugin:eslint-comments/recommended',
|
|
7
|
+
'plugin:import/recommended',
|
|
8
|
+
'plugin:prettier/recommended',
|
|
9
|
+
'plugin:jest/recommended',
|
|
10
|
+
'plugin:jsdoc/recommended',
|
|
11
|
+
'plugin:wdio/recommended',
|
|
12
|
+
'plugin:testing-library/dom',
|
|
13
|
+
'plugin:storybook/recommended',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const basePlugins = ['testing-library', 'jest', 'jsdoc', 'wdio', 'import'];
|
|
17
|
+
exports.basePlugins = basePlugins;
|
|
18
|
+
|
|
19
|
+
exports.baseOverrides = [
|
|
20
|
+
{
|
|
21
|
+
files: ['*.func.spec.js', '*.visual.spec.js'],
|
|
22
|
+
rules: {
|
|
23
|
+
'jest/valid-expect': 'off',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const baseRules = {
|
|
29
|
+
'prettier/prettier': ['error', prettierOptions],
|
|
30
|
+
'arrow-body-style': [2, 'as-needed'],
|
|
31
|
+
'class-methods-use-this': 0,
|
|
32
|
+
'import/imports-first': 0,
|
|
33
|
+
'import/newline-after-import': 0,
|
|
34
|
+
'import/no-dynamic-require': 0,
|
|
35
|
+
'import/no-extraneous-dependencies': 0,
|
|
36
|
+
'import/no-named-as-default': 0,
|
|
37
|
+
'import/no-unresolved': [
|
|
38
|
+
2,
|
|
39
|
+
{ caseSensitive: true, caseSensitiveStrict: true },
|
|
40
|
+
], // Tip: https://github.com/import-js/eslint-plugin-import/issues/1868
|
|
41
|
+
'import/no-webpack-loader-syntax': 0,
|
|
42
|
+
'import/prefer-default-export': 0,
|
|
43
|
+
'import/extensions': [
|
|
44
|
+
2,
|
|
45
|
+
'never',
|
|
46
|
+
{
|
|
47
|
+
json: 'ignorePackages',
|
|
48
|
+
js: 'ignorePackages',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
indent: [
|
|
52
|
+
2,
|
|
53
|
+
2,
|
|
54
|
+
{
|
|
55
|
+
SwitchCase: 1,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
'max-lines': ['error', { max: 120, skipComments: true }],
|
|
59
|
+
complexity: ['error', { max: 10 }],
|
|
60
|
+
'max-depth': ['error', { max: 4 }],
|
|
61
|
+
'max-lines-per-function': 0,
|
|
62
|
+
'max-nested-callbacks': ['error', { max: 3 }],
|
|
63
|
+
'max-params': ['error', { max: 3 }],
|
|
64
|
+
'max-statements': ['error', { max: 20 }],
|
|
65
|
+
'max-len': 0,
|
|
66
|
+
'newline-per-chained-call': 0,
|
|
67
|
+
'no-confusing-arrow': 0,
|
|
68
|
+
'no-console': 1,
|
|
69
|
+
'no-param-reassign': ['error', { props: false }],
|
|
70
|
+
'no-unused-vars': 2,
|
|
71
|
+
'no-use-before-define': 0,
|
|
72
|
+
'prefer-template': 2,
|
|
73
|
+
'require-yield': 0,
|
|
74
|
+
'jsdoc/require-jsdoc': 0,
|
|
75
|
+
'eslint-comments/disable-enable-pair': 0,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.baseRules = baseRules;
|
|
79
|
+
|
|
80
|
+
const reactRules = {
|
|
81
|
+
'jsx-a11y/aria-props': 2,
|
|
82
|
+
'jsx-a11y/heading-has-content': 0,
|
|
83
|
+
'jsx-a11y/label-has-associated-control': [
|
|
84
|
+
2,
|
|
85
|
+
{
|
|
86
|
+
// NOTE: If this error triggers, either disable it or add
|
|
87
|
+
// your custom components, labels and attributes via these options
|
|
88
|
+
// See https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-associated-control.md
|
|
89
|
+
controlComponents: ['Input'],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
'jsx-a11y/label-has-for': 0,
|
|
93
|
+
'jsx-a11y/mouse-events-have-key-events': 2,
|
|
94
|
+
'jsx-a11y/role-has-required-aria-props': 2,
|
|
95
|
+
'jsx-a11y/role-supports-aria-props': 2,
|
|
96
|
+
'react/destructuring-assignment': 0,
|
|
97
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
98
|
+
'react/jsx-closing-tag-location': 0,
|
|
99
|
+
'react/forbid-prop-types': 0,
|
|
100
|
+
'react/jsx-first-prop-new-line': [2, 'multiline'],
|
|
101
|
+
'react/jsx-no-target-blank': 0,
|
|
102
|
+
'react/jsx-props-no-spreading': 0,
|
|
103
|
+
'react/jsx-uses-vars': 2,
|
|
104
|
+
'react/require-default-props': 0,
|
|
105
|
+
'react/require-extension': 0,
|
|
106
|
+
'react/self-closing-comp': 0,
|
|
107
|
+
'react/sort-comp': 0,
|
|
108
|
+
'react/react-in-jsx-scope': 0,
|
|
109
|
+
'react/jsx-filename-extension': [
|
|
110
|
+
1,
|
|
111
|
+
{ extensions: ['.js', '.jsx', '.tsx', '.mdx'] },
|
|
112
|
+
],
|
|
113
|
+
'react/function-component-definition': [
|
|
114
|
+
2,
|
|
115
|
+
{ namedComponents: 'arrow-function' },
|
|
116
|
+
],
|
|
117
|
+
'redux-saga/no-yield-in-race': 2,
|
|
118
|
+
'redux-saga/yield-effects': 2,
|
|
119
|
+
};
|
|
120
|
+
exports.reactRules = reactRules;
|
|
121
|
+
|
|
122
|
+
exports.baseConfig = {
|
|
123
|
+
parser: '@babel/eslint-parser',
|
|
124
|
+
plugins: basePlugins,
|
|
125
|
+
env: {
|
|
126
|
+
jest: true,
|
|
127
|
+
browser: true,
|
|
128
|
+
node: true,
|
|
129
|
+
es2021: true,
|
|
130
|
+
},
|
|
131
|
+
parserOptions: {
|
|
132
|
+
sourceType: 'module',
|
|
133
|
+
ecmaFeatures: {
|
|
134
|
+
jsx: true,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
settings: {
|
|
138
|
+
react: {
|
|
139
|
+
version: 'detect',
|
|
140
|
+
},
|
|
141
|
+
jest: {
|
|
142
|
+
version: 28,
|
|
143
|
+
},
|
|
144
|
+
'import/resolver': {
|
|
145
|
+
node: {
|
|
146
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx']
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
ignorePatterns: [
|
|
151
|
+
'/build/**/*',
|
|
152
|
+
'/dist/**/*',
|
|
153
|
+
'/reports/**/*',
|
|
154
|
+
'/coverage/**/*',
|
|
155
|
+
'/demo/**/*',
|
|
156
|
+
'/docs/**/*',
|
|
157
|
+
'/temp/**/*',
|
|
158
|
+
'**/vendor/*.js',
|
|
159
|
+
],
|
|
160
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const {
|
|
2
|
+
baseExtends,
|
|
3
|
+
baseRules,
|
|
4
|
+
baseOverrides,
|
|
5
|
+
baseConfig,
|
|
6
|
+
} = require('./common.cjs');
|
|
7
|
+
const { tsConfig } = require('./typescript/non-react.cjs');
|
|
8
|
+
|
|
9
|
+
exports.esConfig = {
|
|
10
|
+
...baseConfig,
|
|
11
|
+
extends: ['airbnb-base'].concat(baseExtends),
|
|
12
|
+
rules: baseRules,
|
|
13
|
+
overrides: baseOverrides.concat([tsConfig]),
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const {
|
|
2
|
+
baseExtends,
|
|
3
|
+
baseRules,
|
|
4
|
+
baseOverrides,
|
|
5
|
+
baseConfig,
|
|
6
|
+
reactRules,
|
|
7
|
+
} = require('./common.cjs');
|
|
8
|
+
const { tsReactConfig } = require('./typescript/react.cjs');
|
|
9
|
+
|
|
10
|
+
exports.esReactConfig = {
|
|
11
|
+
...baseConfig,
|
|
12
|
+
extends: ['airbnb', 'airbnb/hooks', 'plugin:redux-saga/recommended'].concat(
|
|
13
|
+
baseExtends,
|
|
14
|
+
),
|
|
15
|
+
rules: {
|
|
16
|
+
...baseRules,
|
|
17
|
+
...reactRules,
|
|
18
|
+
},
|
|
19
|
+
overrides: baseOverrides.concat([
|
|
20
|
+
tsReactConfig,
|
|
21
|
+
{
|
|
22
|
+
files: '*.mdx',
|
|
23
|
+
extends: 'plugin:mdx/recommended',
|
|
24
|
+
},
|
|
25
|
+
]),
|
|
26
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const { baseExtends, basePlugins } = require('../common.cjs');
|
|
2
|
+
|
|
3
|
+
exports.tsBaseExtends = [
|
|
4
|
+
'plugin:@typescript-eslint/recommended',
|
|
5
|
+
'plugin:import/typescript',
|
|
6
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
7
|
+
].concat(baseExtends);
|
|
8
|
+
|
|
9
|
+
exports.tsBaseRules = {
|
|
10
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
11
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
12
|
+
'@typescript-eslint/no-use-before-define': [
|
|
13
|
+
'error',
|
|
14
|
+
{ functions: false, classes: true, variables: true, typedefs: true },
|
|
15
|
+
],
|
|
16
|
+
'max-lines': ['error', { max: 200, skipComments: true }],
|
|
17
|
+
'@typescript-eslint/unbound-method': [
|
|
18
|
+
'error',
|
|
19
|
+
{
|
|
20
|
+
ignoreStatic: true,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.tsBaseConfig = {
|
|
26
|
+
files: ['*.ts', '*.tsx'],
|
|
27
|
+
parser: '@typescript-eslint/parser',
|
|
28
|
+
plugins: ['@typescript-eslint'].concat(basePlugins),
|
|
29
|
+
parserOptions: {
|
|
30
|
+
tsconfigRootDir: process.cwd(),
|
|
31
|
+
project: 'tsconfig.json',
|
|
32
|
+
},
|
|
33
|
+
settings: {
|
|
34
|
+
'import/resolver': {
|
|
35
|
+
typescript: {
|
|
36
|
+
alwaysTryTypes: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
'import/parsers': {
|
|
40
|
+
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
const { baseRules } = require('../common.cjs');
|
|
3
|
+
const { tsBaseExtends, tsBaseRules, tsBaseConfig } = require('./common.cjs');
|
|
4
|
+
|
|
5
|
+
exports.tsConfig = {
|
|
6
|
+
...tsBaseConfig,
|
|
7
|
+
extends: ['airbnb-base', 'airbnb-typescript/base'].concat(tsBaseExtends),
|
|
8
|
+
rules: {
|
|
9
|
+
...baseRules,
|
|
10
|
+
...tsBaseRules,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
const { baseRules, reactRules } = require('../common.cjs');
|
|
3
|
+
const { tsBaseExtends, tsBaseRules, tsBaseConfig } = require('./common.cjs');
|
|
4
|
+
|
|
5
|
+
exports.tsReactConfig = {
|
|
6
|
+
...tsBaseConfig,
|
|
7
|
+
extends: [
|
|
8
|
+
'airbnb',
|
|
9
|
+
'airbnb/hooks',
|
|
10
|
+
'plugin:redux-saga/recommended',
|
|
11
|
+
'airbnb-typescript',
|
|
12
|
+
].concat(tsBaseExtends),
|
|
13
|
+
rules: {
|
|
14
|
+
...baseRules,
|
|
15
|
+
...tsBaseRules,
|
|
16
|
+
...reactRules,
|
|
17
|
+
'react/prop-types': 0,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
const npmClient = fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml")) ? "pnpm" : "npm";
|
|
4
|
+
const lintStagedConfig = {
|
|
5
|
+
"*.{js,ts,jsx,tsx,md,mdx,html,css,json}": ["prettier --write"],
|
|
6
|
+
"*.{ts,tsx}": [`${npmClient} run tscheck`],
|
|
7
|
+
"*.{js,ts,jsx,tsx}": [
|
|
8
|
+
`${npmClient} run lint:fix`,
|
|
9
|
+
`${npmClient} run test:staged`
|
|
10
|
+
]
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
lintStagedConfig
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
exports.stylelintConfig = {
|
|
2
|
+
ignoreFiles: [
|
|
3
|
+
'/dist/**/*',
|
|
4
|
+
'/coverage/**/*',
|
|
5
|
+
'/build/**/*',
|
|
6
|
+
'/reports/**/*',
|
|
7
|
+
'/temp/**/*',
|
|
8
|
+
'/docs/**/*',
|
|
9
|
+
'/demo/**/*',
|
|
10
|
+
'/node_modules/**/*',
|
|
11
|
+
'/vendor/**/*',
|
|
12
|
+
],
|
|
13
|
+
customSyntax: '@stylelint/postcss-css-in-js',
|
|
14
|
+
extends: [
|
|
15
|
+
'stylelint-config-recommended',
|
|
16
|
+
'stylelint-config-styled-components',
|
|
17
|
+
],
|
|
18
|
+
rules: { 'selector-type-no-unknown': null, 'no-extra-semicolons': null, 'function-no-unknown': null },
|
|
19
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
const cwd = process.cwd();
|
|
3
|
+
const execaOptions = { cwd, stdio: "inherit" };
|
|
4
|
+
const semVerRegEx = /^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-]+)*))?$/;
|
|
5
|
+
const isSemVersion = (tagName) => semVerRegEx.test(tagName);
|
|
6
|
+
const branchName = (process.env.BRANCH_NAME || "master").toLowerCase();
|
|
7
|
+
const branchTags = {
|
|
8
|
+
master: /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/,
|
|
9
|
+
next: /^v.*-next\.(0|[1-9]\d*)/,
|
|
10
|
+
alpha: /^v.*-alpha\.(0|[1-9]\d*)/,
|
|
11
|
+
beta: /^v.*-beta\.(0|[1-9]\d*)/
|
|
12
|
+
};
|
|
13
|
+
const deleteTags = (cmd, filter) => {
|
|
14
|
+
const result = execSync(cmd, { cwd });
|
|
15
|
+
if (!result)
|
|
16
|
+
return;
|
|
17
|
+
const tags = result.toString().split("\n").join(" ");
|
|
18
|
+
execSync(`git tag -d ${filter ? filter(tags) : tags}`, { cwd });
|
|
19
|
+
};
|
|
20
|
+
const tagsFromOtherBranches = (tags = []) => {
|
|
21
|
+
const regex = branchTags[branchName] || branchTags.master;
|
|
22
|
+
return tags.split(" ").filter((tagName) => isSemVersion(tagName) && !regex.test(tagName)).join(" ");
|
|
23
|
+
};
|
|
24
|
+
const deleteMergedTags = () => {
|
|
25
|
+
try {
|
|
26
|
+
if (branchName) {
|
|
27
|
+
deleteTags(`git tag -l --no-merged ${branchName}`);
|
|
28
|
+
deleteTags(`git tag -l --merged ${branchName}`, tagsFromOtherBranches);
|
|
29
|
+
console.log("Last two tags: ");
|
|
30
|
+
execSync("git tag --sort=-creatordate | head -n 2", execaOptions);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(error);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
deleteMergedTags
|
|
38
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
import normalizePath from "normalize-path";
|
|
4
|
+
import { findMonoRepoRoot } from "./utils.cjs";
|
|
5
|
+
const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
|
|
6
|
+
const setRegistryVersion = async () => {
|
|
7
|
+
const files = await fg([
|
|
8
|
+
`${monorepoRoot}/libs/*/package.json`,
|
|
9
|
+
`${monorepoRoot}/apps/*/package.json`,
|
|
10
|
+
`${monorepoRoot}/package.json`
|
|
11
|
+
]);
|
|
12
|
+
Promise.all(
|
|
13
|
+
files.map(async (file) => {
|
|
14
|
+
let pkgJSONData = await readFile(file, "utf8");
|
|
15
|
+
const pkgVersion = JSON.parse(pkgJSONData).version;
|
|
16
|
+
pkgJSONData = pkgJSONData.replace(/workspace:\*/g, pkgVersion);
|
|
17
|
+
await writeFile(file, pkgJSONData);
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
setRegistryVersion
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
import normalizePath from "normalize-path";
|
|
4
|
+
import { findMonoRepoRoot } from "./utils.cjs";
|
|
5
|
+
const monorepoRoot = normalizePath(findMonoRepoRoot() || "");
|
|
6
|
+
const setWorkspaceVersion = async () => {
|
|
7
|
+
const files = await fg([
|
|
8
|
+
`${monorepoRoot}/libs/*/package.json`,
|
|
9
|
+
`${monorepoRoot}/apps/*/package.json`,
|
|
10
|
+
`${monorepoRoot}/package.json`
|
|
11
|
+
]);
|
|
12
|
+
Promise.all(
|
|
13
|
+
files.map(async (file) => {
|
|
14
|
+
let pkgJSONData = await readFile(file, "utf8");
|
|
15
|
+
const pkgVersion = JSON.parse(pkgJSONData).version;
|
|
16
|
+
pkgJSONData = pkgJSONData.replace(
|
|
17
|
+
new RegExp(pkgVersion, "g"),
|
|
18
|
+
"workspace:*"
|
|
19
|
+
);
|
|
20
|
+
pkgJSONData = pkgJSONData.replace(
|
|
21
|
+
/"version": "workspace:\*"/g,
|
|
22
|
+
`"version": "${pkgVersion}"`
|
|
23
|
+
);
|
|
24
|
+
await writeFile(file, pkgJSONData);
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
setWorkspaceVersion
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
|
|
4
|
+
const WORKSPACE_DIR_ENV_VAR = 'NPM_CONFIG_WORKSPACE_DIR';
|
|
5
|
+
const WORKSPACE_MANIFEST_FILENAME = 'pnpm-workspace.yaml';
|
|
6
|
+
|
|
7
|
+
const getPNPMWorkspaceLocation = (cwd) => {
|
|
8
|
+
let location = null;
|
|
9
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
for (const fileName of [WORKSPACE_MANIFEST_FILENAME, 'pnpm-workspace.yml']) {
|
|
11
|
+
try {
|
|
12
|
+
const result = execSync(`npx find-up ${fileName}`, { cwd });
|
|
13
|
+
location = result.toString().trim();
|
|
14
|
+
break;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
// ignore
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return location;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.findMonoRepoRoot = (cwd = process.cwd()) => {
|
|
23
|
+
const workspaceManifestDirEnvVar =
|
|
24
|
+
process.env[WORKSPACE_DIR_ENV_VAR] ??
|
|
25
|
+
process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
|
|
26
|
+
const workspaceManifestLocation = workspaceManifestDirEnvVar
|
|
27
|
+
? path.join(workspaceManifestDirEnvVar, 'pnpm-workspace.yaml')
|
|
28
|
+
: getPNPMWorkspaceLocation(cwd);
|
|
29
|
+
return workspaceManifestLocation && path.dirname(workspaceManifestLocation);
|
|
30
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { merge } from "lodash";
|
|
4
|
+
const baseConfig = {
|
|
5
|
+
esBuild: {
|
|
6
|
+
target: "es2020"
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const getPUIConfig = () => {
|
|
10
|
+
const configPath = path.resolve(process.cwd(), "./pui.config.js");
|
|
11
|
+
if (!fs.existsSync(configPath))
|
|
12
|
+
return baseConfig;
|
|
13
|
+
const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
14
|
+
return merge(baseConfig, config);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
getPUIConfig
|
|
18
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
branches: [
|
|
3
|
+
'+([0-9])?(.{+([0-9]),x}).x',
|
|
4
|
+
'master',
|
|
5
|
+
'next-major',
|
|
6
|
+
{ name: 'beta', prerelease: true },
|
|
7
|
+
{ name: 'alpha', prerelease: true },
|
|
8
|
+
{ name: 'hotfix', prerelease: true },
|
|
9
|
+
{ name: 'next', prerelease: true },
|
|
10
|
+
],
|
|
11
|
+
plugins: [
|
|
12
|
+
'@semantic-release/commit-analyzer',
|
|
13
|
+
'@semantic-release/release-notes-generator',
|
|
14
|
+
[
|
|
15
|
+
'@semantic-release/changelog',
|
|
16
|
+
{
|
|
17
|
+
changelogTitle:
|
|
18
|
+
'# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
'@semantic-release/npm',
|
|
22
|
+
'@semantic-release/github',
|
|
23
|
+
[
|
|
24
|
+
'@semantic-release/exec',
|
|
25
|
+
{
|
|
26
|
+
successCmd:
|
|
27
|
+
'scmutil get slack-release-notes && scmutil get contributors',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
],
|
|
31
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const allJS = /\.js$/;
|
|
5
|
+
|
|
6
|
+
const serviceEndpoints = /\.endpoint\.js$/;
|
|
7
|
+
|
|
8
|
+
const getFilesMatching = (filePattern) => {
|
|
9
|
+
const getFiles = (dir) => {
|
|
10
|
+
let routeFiles = [];
|
|
11
|
+
if (!fs.existsSync(dir)) return routeFiles;
|
|
12
|
+
fs.readdirSync(dir).forEach((file) => {
|
|
13
|
+
const fullPath = path.join(dir, file);
|
|
14
|
+
if (fs.lstatSync(fullPath).isDirectory()) {
|
|
15
|
+
routeFiles = routeFiles.concat(getFiles(fullPath));
|
|
16
|
+
} else if (filePattern.test(fullPath)) routeFiles.push(fullPath);
|
|
17
|
+
});
|
|
18
|
+
return routeFiles;
|
|
19
|
+
};
|
|
20
|
+
return getFiles;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getServerRouteFiles = getFilesMatching(allJS);
|
|
24
|
+
const getServiceEndpoints = getFilesMatching(serviceEndpoints);
|
|
25
|
+
|
|
26
|
+
exports.loadRoutes = (app) => {
|
|
27
|
+
const routeFiles = getServerRouteFiles(
|
|
28
|
+
path.join(process.cwd(), 'server/routes'),
|
|
29
|
+
);
|
|
30
|
+
routeFiles.push(...getServiceEndpoints(path.join(process.cwd(), 'app')));
|
|
31
|
+
routeFiles.push(...getServiceEndpoints(path.join(process.cwd(), 'lib')));
|
|
32
|
+
routeFiles.forEach((routeFile) => {
|
|
33
|
+
// eslint-disable-next-line global-require
|
|
34
|
+
const init = require(routeFile);
|
|
35
|
+
try {
|
|
36
|
+
init(app);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
console.error(`unable to load routes from ${routeFile}. ${err.message}`);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import cspPolicy from "helmet-csp";
|
|
4
|
+
import crypto from "crypto";
|
|
5
|
+
const sources = [
|
|
6
|
+
"'self'",
|
|
7
|
+
"http://localhost:*",
|
|
8
|
+
"*.elliemae.io",
|
|
9
|
+
"*.elliemae.com",
|
|
10
|
+
"*.elliservices.com",
|
|
11
|
+
"*.ellielabs.com",
|
|
12
|
+
"http://pdx-col.eum-appdynamics.com",
|
|
13
|
+
"https://pdx-col.eum-appdynamics.com/",
|
|
14
|
+
"https://www.google-analytics.com",
|
|
15
|
+
"https://www.googletagmanager.com"
|
|
16
|
+
];
|
|
17
|
+
const sendFileWithCSPNonce = ({
|
|
18
|
+
buildPath,
|
|
19
|
+
page = "index.html",
|
|
20
|
+
nonceRegex = /__CSP_NONCE__/g,
|
|
21
|
+
res,
|
|
22
|
+
fileSystem = fs
|
|
23
|
+
}) => {
|
|
24
|
+
fileSystem.readFile(path.resolve(buildPath, page), "utf8", (err, html) => {
|
|
25
|
+
if (err) {
|
|
26
|
+
res.sendStatus(404);
|
|
27
|
+
} else {
|
|
28
|
+
res.set("Content-Type", "text/html");
|
|
29
|
+
res.send(html.replace(nonceRegex, (res.locals || {}).cspNonce));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const getScriptSrc = () => {
|
|
34
|
+
const scriptSrc = sources.concat([
|
|
35
|
+
(req, res) => `'nonce-${res.locals.cspNonce}'`
|
|
36
|
+
]);
|
|
37
|
+
return true ? scriptSrc.concat(["'unsafe-eval'"]) : scriptSrc;
|
|
38
|
+
};
|
|
39
|
+
const csp = (app) => {
|
|
40
|
+
app.use((req, res, next) => {
|
|
41
|
+
res.locals.cspNonce = crypto.randomBytes(16).toString("hex");
|
|
42
|
+
next();
|
|
43
|
+
});
|
|
44
|
+
app.use(
|
|
45
|
+
cspPolicy({
|
|
46
|
+
directives: {
|
|
47
|
+
defaultSrc: ["'self'"],
|
|
48
|
+
baseUri: ["'self'"],
|
|
49
|
+
blockAllMixedContent: [],
|
|
50
|
+
connectSrc: sources,
|
|
51
|
+
fontSrc: sources.concat(["data:"]),
|
|
52
|
+
frameAncestors: sources,
|
|
53
|
+
imgSrc: sources.concat(["data:"]),
|
|
54
|
+
objectSrc: ["'none'"],
|
|
55
|
+
scriptSrc: getScriptSrc(),
|
|
56
|
+
scriptSrcAttr: ["'none'"],
|
|
57
|
+
styleSrc: sources.concat(["'unsafe-inline'"]),
|
|
58
|
+
upgradeInsecureRequests: [],
|
|
59
|
+
reportUri: "/v1/csp"
|
|
60
|
+
},
|
|
61
|
+
reportOnly: true
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
csp,
|
|
67
|
+
sendFileWithCSPNonce
|
|
68
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { logger } from "./logger.js";
|
|
3
|
+
import {
|
|
4
|
+
setupDefaultMiddlewares,
|
|
5
|
+
setupAdditionalMiddlewars
|
|
6
|
+
} from "./middlewares.js";
|
|
7
|
+
import { port, host } from "./utils.js";
|
|
8
|
+
import { loadRoutes } from "./app-routes.cjs";
|
|
9
|
+
const app = express();
|
|
10
|
+
setupDefaultMiddlewares(app);
|
|
11
|
+
loadRoutes(app);
|
|
12
|
+
setupAdditionalMiddlewars(app);
|
|
13
|
+
app.listen(port, host, async (err) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
return logger.error(err.message);
|
|
16
|
+
}
|
|
17
|
+
logger.appStarted(port, host || "localhost");
|
|
18
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import ip from "ip";
|
|
3
|
+
const divider = chalk.gray("\n-----------------------------------");
|
|
4
|
+
const logger = {
|
|
5
|
+
error: (err) => {
|
|
6
|
+
console.error(chalk.red(err));
|
|
7
|
+
},
|
|
8
|
+
appStarted: (port, host, tunnelStarted) => {
|
|
9
|
+
console.log(`Server started ! ${chalk.green("\u2713")}`);
|
|
10
|
+
if (tunnelStarted) {
|
|
11
|
+
console.log(`Tunnel initialised ${chalk.green("\u2713")}`);
|
|
12
|
+
}
|
|
13
|
+
const accessUrls = `${chalk.bold("Access URLs:")}${divider}
|
|
14
|
+
`;
|
|
15
|
+
const localHostUrl = `Localhost: ${chalk.magenta(
|
|
16
|
+
`http://${host}:${port}`
|
|
17
|
+
)}
|
|
18
|
+
`;
|
|
19
|
+
const lanUrl = `LAN: ${chalk.magenta(`http://${ip.address()}:${port}`)}
|
|
20
|
+
`;
|
|
21
|
+
const proxy = tunnelStarted ? `
|
|
22
|
+
Proxy: ${chalk.magenta(tunnelStarted)}` : "";
|
|
23
|
+
console.log(`${accessUrls}${localHostUrl}${lanUrl}${proxy}${divider}${chalk.blue(
|
|
24
|
+
`
|
|
25
|
+
Press ${chalk.italic("CTRL-C")} to stop`
|
|
26
|
+
)}
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
logger
|
|
32
|
+
};
|