@epic-effx/create-application-template-rs 0.1.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.
Files changed (51) hide show
  1. package/.babelrc +14 -0
  2. package/.browserslistrc +3 -0
  3. package/.codex +0 -0
  4. package/.eslintrc.js +309 -0
  5. package/.husky/pre-commit +5 -0
  6. package/.stylelintrc.js +29 -0
  7. package/LICENSE +21 -0
  8. package/README.md +141 -0
  9. package/bin/create-application-template-rs.js +116 -0
  10. package/jest/cssTransform.js +13 -0
  11. package/jest/fontTransform.js +12 -0
  12. package/jest/setup.js +5 -0
  13. package/jest/setupTests.js +15 -0
  14. package/jest/svgTransform.js +12 -0
  15. package/jest.config.js +58 -0
  16. package/package.json +117 -0
  17. package/rspack/rspack.common.js +212 -0
  18. package/rspack/rspack.config.js +14 -0
  19. package/rspack/rspack.dev.js +36 -0
  20. package/rspack/rspack.prod.js +43 -0
  21. package/rspack/utilities/createEnvironmentHash.js +8 -0
  22. package/rspack/utilities/env.js +8 -0
  23. package/rspack/utilities/generateAssetManifest.js +16 -0
  24. package/rspack/utilities/getPaths.js +57 -0
  25. package/rspack/utilities/getTerserOptions.js +47 -0
  26. package/scripts/generate-sitemap.ts +25 -0
  27. package/src/app.d.ts +7 -0
  28. package/src/assets/favicon.ico +0 -0
  29. package/src/assets/logo.svg +15 -0
  30. package/src/components/App.spec.tsx +24 -0
  31. package/src/components/App.tsx +66 -0
  32. package/src/components/Counter.spec.tsx +38 -0
  33. package/src/components/Counter.tsx +26 -0
  34. package/src/components/Typewriter.spec.tsx +36 -0
  35. package/src/components/Typewriter.tsx +66 -0
  36. package/src/components/__snapshots__/App.spec.tsx.snap +56 -0
  37. package/src/components/__snapshots__/Counter.spec.tsx.snap +44 -0
  38. package/src/components/__snapshots__/Typewriter.spec.tsx.snap +56 -0
  39. package/src/fonts/Exo2-Regular.woff2 +0 -0
  40. package/src/fonts/Orbitron-Regular.woff2 +0 -0
  41. package/src/index.html +18 -0
  42. package/src/index.tsx +12 -0
  43. package/src/public/robots.txt +6 -0
  44. package/src/styles/App.styled.ts +42 -0
  45. package/src/styles/Counter.styled.ts +30 -0
  46. package/src/styles/Global.ts +18 -0
  47. package/src/styles/Logo.styled.ts +24 -0
  48. package/src/styles/Typewriter.styled.ts +5 -0
  49. package/src/styles/env.css +11 -0
  50. package/src/styles/theme.ts +21 -0
  51. package/tsconfig.json +31 -0
package/.babelrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-react",
5
+ {
6
+ "runtime": "automatic"
7
+ }
8
+ ],
9
+ "@babel/preset-typescript"
10
+ ],
11
+ "plugins": [
12
+ "babel-plugin-react-compiler"
13
+ ]
14
+ }
@@ -0,0 +1,3 @@
1
+ # supported browsers
2
+
3
+ defaults and fully supports es6-module
package/.codex ADDED
File without changes
package/.eslintrc.js ADDED
@@ -0,0 +1,309 @@
1
+ const restrictedGlobals = require('confusing-browser-globals')
2
+
3
+ // NOTE use following to address: 'Parsing error: __classPrivateFieldGet(...).at is not a function error'
4
+ // '@typescript-eslint/eslint-plugin': '6.5.0',
5
+ // '@typescript-eslint/parser': '6.5.0',
6
+
7
+ module.exports = {
8
+ root: true,
9
+ parser: '@typescript-eslint/parser',
10
+ parserOptions: {
11
+ ecmaVersion: 2020,
12
+ sourceType: 'module',
13
+ },
14
+ settings: {
15
+ react: {
16
+ version: 'detect',
17
+ },
18
+ },
19
+ extends: [
20
+ 'plugin:react/recommended',
21
+ 'plugin:react-hooks/recommended',
22
+ 'plugin:@typescript-eslint/recommended',
23
+ 'plugin:import/errors',
24
+ 'plugin:import/warnings',
25
+ 'plugin:import/typescript',
26
+ 'plugin:jsx-a11y/recommended',
27
+ 'plugin:eslint-comments/recommended',
28
+ 'plugin:eslint-plugin-compat/recommended',
29
+ ],
30
+ rules: {
31
+ // 📜 @typescript-eslint
32
+ 'quotes': 'off',
33
+ '@typescript-eslint/quotes': ['error', 'single'],
34
+ 'no-dupe-class-members': 'off', // handled by .ts
35
+ 'no-undef': 'off', // handled by .ts
36
+ '@typescript-eslint/consistent-type-assertions': 'error',
37
+ 'no-array-constructor': 'off',
38
+ '@typescript-eslint/no-array-constructor': 'error',
39
+ 'no-var': 'error', // makes 'no-redeclare' irrelevant
40
+ // 'no-redeclare': 'off', // see above
41
+ // '@typescript-eslint/no-redeclare': 'error', // see above
42
+ 'no-use-before-define': 'off',
43
+ '@typescript-eslint/no-use-before-define': [
44
+ 'error',
45
+ {
46
+ 'functions': true,
47
+ 'classes': true,
48
+ 'variables': true,
49
+ 'allowNamedExports': true,
50
+ 'enums': true,
51
+ 'typedefs': true,
52
+ 'ignoreTypeReferences': true,
53
+ },
54
+ ],
55
+ 'no-unused-expressions': 'off',
56
+ '@typescript-eslint/no-unused-expressions': [
57
+ 'error',
58
+ {
59
+ 'allowShortCircuit': true,
60
+ 'allowTernary': true,
61
+ 'allowTaggedTemplates': true,
62
+ },
63
+ ],
64
+ 'no-unused-vars': 'off',
65
+ '@typescript-eslint/no-unused-vars': [
66
+ 'error',
67
+ {
68
+ 'ignoreRestSiblings': true,
69
+ },
70
+ ],
71
+ 'no-useless-constructor': 'off',
72
+ '@typescript-eslint/no-useless-constructor': 'error',
73
+ '@typescript-eslint/no-var-requires': 'off',
74
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
75
+
76
+ // 📜 eslint
77
+ 'array-callback-return': 'error',
78
+ 'default-case': 'error',
79
+ 'dot-location': ['error', 'property'],
80
+ 'eqeqeq': ['error', 'always'],
81
+ 'new-parens': 'error',
82
+ 'no-caller': 'error',
83
+ 'no-cond-assign': ['error', 'except-parens'],
84
+ 'no-const-assign': 'error',
85
+ 'no-control-regex': 'error',
86
+ 'no-delete-var': 'error',
87
+ 'no-dupe-args': 'error',
88
+ 'no-dupe-keys': 'error',
89
+ 'no-duplicate-case': 'error',
90
+ 'no-empty-character-class': 'error',
91
+ 'no-empty-pattern': 'error',
92
+ 'no-eval': 'error',
93
+ 'no-ex-assign': 'error',
94
+ 'no-extend-native': 'error',
95
+ 'no-extra-bind': 'error',
96
+ 'no-extra-label': 'error',
97
+ 'no-fallthrough': 'error',
98
+ 'no-func-assign': 'error',
99
+ 'no-implied-eval': 'error',
100
+ 'no-invalid-regexp': 'error',
101
+ 'no-iterator': 'error',
102
+ 'no-label-var': 'error',
103
+ 'no-labels': [
104
+ 'error',
105
+ {
106
+ 'allowLoop': true,
107
+ 'allowSwitch': false,
108
+ },
109
+ ],
110
+ 'no-lone-blocks': 'error',
111
+ 'no-loop-func': 'error',
112
+ 'no-mixed-operators': [
113
+ 'error',
114
+ {
115
+ 'groups': [
116
+ ['&', '|', '^', '~', '<<', '>>', '>>>'],
117
+ ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
118
+ ['&&', '||'],
119
+ ['in', 'instanceof'],
120
+ ],
121
+ 'allowSamePrecedence': false,
122
+ },
123
+ ],
124
+ 'no-multi-str': 'error',
125
+ 'no-native-reassign': 'error',
126
+ 'no-negated-in-lhs': 'error',
127
+ 'no-new-func': 'error',
128
+ 'no-new-object': 'error',
129
+ 'no-new-symbol': 'error',
130
+ 'no-new-wrappers': 'error',
131
+ 'no-obj-calls': 'error',
132
+ 'no-octal': 'error',
133
+ 'no-octal-escape': 'error',
134
+ 'no-redeclare': 'error',
135
+ 'no-regex-spaces': 'error',
136
+ 'no-restricted-syntax': ['error', 'WithStatement'],
137
+ 'no-script-url': 'error',
138
+ 'no-self-assign': 'error',
139
+ 'no-self-compare': 'error',
140
+ 'no-sequences': 'error',
141
+ 'no-shadow-restricted-names': 'error',
142
+ 'no-sparse-arrays': 'error',
143
+ 'no-template-curly-in-string': 'error',
144
+ 'no-this-before-super': 'error',
145
+ 'no-throw-literal': 'error',
146
+ 'no-restricted-globals': ['error'].concat(restrictedGlobals),
147
+ 'no-unreachable': 'error',
148
+ 'no-unused-labels': 'error',
149
+ 'no-useless-computed-key': 'error',
150
+ 'no-useless-concat': 'error',
151
+ 'no-useless-escape': 'error',
152
+ 'no-useless-rename': [
153
+ 'error',
154
+ {
155
+ 'ignoreDestructuring': false,
156
+ 'ignoreImport': false,
157
+ 'ignoreExport': false,
158
+ },
159
+ ],
160
+ 'no-with': 'error',
161
+ 'no-whitespace-before-property': 'error',
162
+ 'react-hooks/exhaustive-deps': 'error',
163
+ 'require-yield': 'error',
164
+ 'rest-spread-spacing': ['error', 'never'],
165
+ 'strict': ['error', 'never'],
166
+ 'unicode-bom': ['error', 'never'],
167
+ 'use-isnan': 'error',
168
+ 'valid-typeof': 'error',
169
+ 'no-restricted-properties': [
170
+ 'error',
171
+ {
172
+ 'object': 'require',
173
+ 'property': 'ensure',
174
+ 'message': 'use import() instead',
175
+ },
176
+ {
177
+ 'object': 'System',
178
+ 'property': 'import',
179
+ 'message': 'use import() instead',
180
+ },
181
+ ],
182
+ 'getter-return': 'error',
183
+
184
+ // 📜 eslint, some additional styles
185
+ 'array-element-newline': ['error', 'consistent'],
186
+ 'comma-dangle': ['error', {
187
+ 'arrays': 'always-multiline',
188
+ 'objects': 'always-multiline',
189
+ 'imports': 'always-multiline',
190
+ 'exports': 'always-multiline',
191
+ // 'functions': 'never'
192
+ }],
193
+ 'semi': ['error', 'never'],
194
+ 'curly': ['error', 'multi-line'],
195
+ 'indent': [
196
+ 'error',
197
+ 2,
198
+ {
199
+ 'SwitchCase': 1,
200
+ },
201
+ ],
202
+ 'arrow-spacing': ['error'],
203
+ 'object-curly-spacing': ['error', 'always'],
204
+ 'array-bracket-spacing': ['error', 'never'],
205
+ 'no-irregular-whitespace': ['error'],
206
+ 'eol-last': ['error', 'always'],
207
+ 'no-trailing-spaces': [
208
+ 'error',
209
+ {
210
+ 'skipBlankLines': false,
211
+ 'ignoreComments': true,
212
+ },
213
+ ],
214
+ 'jsx-quotes': ['error', 'prefer-single'],
215
+ 'comma-spacing': ['error', {
216
+ before: false,
217
+ after: true,
218
+ }],
219
+
220
+ // 📜 import
221
+ 'import/first': 'error',
222
+ 'import/no-amd': 'error',
223
+ 'import/no-anonymous-default-export': 'error',
224
+ 'import/no-webpack-loader-syntax': 'error',
225
+
226
+ // 📜 react
227
+ 'react/prop-types': 'off',
228
+ 'react/jsx-uses-react': 'off',
229
+ 'react/react-in-jsx-scope': 'off',
230
+ 'react/forbid-foreign-prop-types': [
231
+ 'error',
232
+ {
233
+ 'allowInPropTypes': true,
234
+ },
235
+ ],
236
+ 'react/jsx-no-comment-textnodes': 'error',
237
+ 'react/jsx-no-duplicate-props': 'error',
238
+ 'react/jsx-no-target-blank': 'error',
239
+ 'react/jsx-no-undef': 'error',
240
+ 'react/jsx-pascal-case': [
241
+ 'error',
242
+ {
243
+ 'allowAllCaps': true,
244
+ 'ignore': [],
245
+ },
246
+ ],
247
+ 'react/no-danger-with-children': 'error',
248
+ // Disabled because of undesirable warnings
249
+ // 'react/no-deprecated': 'error',
250
+ 'react/no-direct-mutation-state': 'error',
251
+ 'react/no-is-mounted': 'error',
252
+ 'react/no-typos': 'error',
253
+ 'react/require-render-return': 'error',
254
+ 'react/style-prop-object': 'error',
255
+
256
+ // 📜 react, some additional styles
257
+ 'react/jsx-child-element-spacing': 'error',
258
+ 'react/jsx-closing-bracket-location': 'error',
259
+ 'react/jsx-closing-tag-location': 'error',
260
+ 'react/jsx-curly-newline': [
261
+ 'error',
262
+ {
263
+ 'multiline': 'consistent',
264
+ 'singleline': 'consistent',
265
+ },
266
+ ],
267
+ 'react/jsx-equals-spacing': ['error', 'never'],
268
+ 'react/jsx-indent': ['error', 2],
269
+ 'react/jsx-indent-props': ['error', 2],
270
+ 'react/jsx-props-no-multi-spaces': 'error',
271
+
272
+ // 📜 jsx-a11y
273
+ 'jsx-a11y/click-events-have-key-events': 'off', // could cause accidental clicks
274
+ 'jsx-a11y/alt-text': 'error',
275
+ 'jsx-a11y/anchor-has-content': 'error',
276
+ 'jsx-a11y/anchor-is-valid': [
277
+ 'error',
278
+ {
279
+ 'aspects': ['noHref', 'invalidHref'],
280
+ },
281
+ ],
282
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
283
+ 'jsx-a11y/aria-props': 'error',
284
+ 'jsx-a11y/aria-proptypes': 'error',
285
+ 'jsx-a11y/aria-role': [
286
+ 'error',
287
+ {
288
+ 'ignoreNonDOM': true,
289
+ },
290
+ ],
291
+ 'jsx-a11y/aria-unsupported-elements': 'error',
292
+ 'jsx-a11y/heading-has-content': 'error',
293
+ 'jsx-a11y/iframe-has-title': 'error',
294
+ 'jsx-a11y/img-redundant-alt': 'error',
295
+ 'jsx-a11y/no-access-key': 'error',
296
+ 'jsx-a11y/no-distracting-elements': 'error',
297
+ 'jsx-a11y/no-redundant-roles': 'error',
298
+ 'jsx-a11y/role-has-required-aria-props': 'error',
299
+ 'jsx-a11y/role-supports-aria-props': 'error',
300
+ 'jsx-a11y/scope': 'error',
301
+
302
+ // 📜 react-hooks
303
+ 'react-hooks/rules-of-hooks': 'error',
304
+
305
+ // 'flowtype/define-flow-type': 'error',
306
+ // 'flowtype/require-valid-file-annotation': 'error',
307
+ // 'flowtype/use-flow-type': 'error',
308
+ },
309
+ }
@@ -0,0 +1,5 @@
1
+ npm run lint
2
+ npm run stylelint
3
+ # use below if you wish to use .css (see README.md "styles")
4
+ # npm run stylelint:css
5
+ npm run test
@@ -0,0 +1,29 @@
1
+ // NOTE if you wish to use .css (see README.md "styles")
2
+ // - remove customSyntax and use "npm stylelint:css"
3
+ // - remove 'value-keyword-case', particularly 'ignoreKeywords'
4
+
5
+ module.exports = {
6
+ extends: [
7
+ 'stylelint-config-standard',
8
+ 'stylelint-config-recess-order',
9
+ 'stylelint-no-unsupported-browser-features',
10
+ ],
11
+
12
+ customSyntax: 'postcss-styled-components',
13
+ ignoreFiles: [],
14
+ rules: {
15
+ 'selector-class-pattern': null,
16
+ 'keyframes-name-pattern': null,
17
+ 'comment-empty-line-before': 'never',
18
+ 'declaration-empty-line-before': 'never',
19
+ 'media-feature-range-notation': 'prefix',
20
+ 'value-keyword-case': [
21
+ 'lower',
22
+ {
23
+ 'ignoreKeywords': [
24
+ '/^POSTCSS_styled-components_\\d+$/',
25
+ ],
26
+ },
27
+ ],
28
+ },
29
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 daveKontro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ ![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FdaveKontro%2Fcreate-application-template-rs%2Fmain%2Fpackage.json&query=%24.version&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAEnRFWHRfcV9pY29PcmlnRGVwdGgAMzLV4rjsAAABRUlEQVQ4jcWSP0tCYRyFz++9gV3KCEoroxZxSiLEoCT7MwUGrQ1tfoD28AMEFTQ1F40OOWVLcPMSDqENrU0SBHUpQrA/cr2nQTEwSm8QnfGF5znnhR/w35HWh0LuYUsoYZara9HV0RcAMAyjy6uFjwi+Tc/7k98Krs4fZym1CxFRNfJYHJUCAApTSrgOAEKsRBb9p18E+fyt7rH1MwFjP24mrquV5/hMIlQGAAUA6XRa67b1TFu4Xjnp6e0/yWZvPE1BcHhpA+ByW7g5AnNDPX2bjS9QiqZVEshYpwIAoEOrTF9ACqY1ooA7N/Bn1IT6HViPbVdFAKCYuy+JqHFXNPHkrQwG6gtE23HbLsLdUELeFQBE4gP74mCPJDuBa5CDqbhvG2i9RMOKQkOSDmJQCILUG3WvdFDSlFySzmFkwW+6Xfx3+QCAd27zrNWLdgAAAABJRU5ErkJggg==&label=version&labelColor=%23081e28&color=%23fd05a0)
2
+ ![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2FdaveKontro%2Fcreate-application-template-rs%2Fmain%2Fpackage.json&query=%24.engines.node&logo=nodedotjs&label=node&labelColor=%23081e28&color=%23fd05a0)
3
+ ![Static Badge](https://img.shields.io/badge/npm->=v10-%23fd05a0?logo=npm&labelColor=%23081e28)
4
+
5
+ # Create Application Template RS
6
+ This project aims to provide a configured application template for you to build upon.
7
+
8
+ All configuration is fully visible and under your control to augment as you see fit.
9
+
10
+ The template is a typescript enabled React application with a test suite and code linting.
11
+
12
+ Rust-based 🦀 web bundler [Rspack](https://rspack.rs/) and compiler [SWC](https://swc.rs/) are utilized for fast bundling and transpiling
13
+
14
+ See the template running live [here](https://www.createapplicationtemplaters.com/).
15
+
16
+ ## installation
17
+ first install globally
18
+ ```
19
+ npm install -g @epic-effx/create-application-template-rs@latest
20
+ ```
21
+
22
+ then create your project
23
+ ```
24
+ npx @epic-effx/create-application-template-rs --name={my-project}
25
+ ```
26
+
27
+ ## usage
28
+ webpack is used for code bundling and the development server
29
+
30
+ run development server and test suite (on http://localhost:3333 by default)
31
+ ```
32
+ npm run dev
33
+ ```
34
+
35
+ build static bundle
36
+ ```
37
+ npm run build
38
+ ```
39
+
40
+ ## compiler 🚀
41
+ this project uses React 19 with [React Compiler](https://react.dev/learn/react-compiler/introduction) opt-in
42
+
43
+ it takes advantage of the React Compiler's automatic optimization
44
+
45
+ React Compiler's ESLint integration is also included via `eslint-plugin-react-hooks`
46
+
47
+ `babel-loader` is used for compilation; see Rspack [docs](https://rspack.rs/guide/tech/react#react-compiler)
48
+
49
+ ## tsconfig
50
+ focused on type checking; SWC is used for transpiling
51
+
52
+ ## pre-commit
53
+ scripts in `.husky/pre-commit` are run on commits for quality control
54
+
55
+ add or remove scripts you'd like run before code is committed
56
+
57
+ ## test suite
58
+ to create a test follow this file naming format: `*.{spec,test}.{ts,tsx}`
59
+
60
+ run the test suite stand alone like so
61
+ ```
62
+ npm run test
63
+ ```
64
+
65
+ ## code linting
66
+ linting rules are in `.eslintrc.js`; install the ESLint plugin if using vscode
67
+ ```
68
+ npm run lint
69
+ ```
70
+
71
+ css linting rules are in `.stylelintrc.js`; install the Stylelint plugin if using vscode
72
+ ```
73
+ npm run stylelint
74
+ ```
75
+
76
+ ## styles
77
+ styling is done using the style-components module, but straight CSS is supported
78
+
79
+ after instillation it is recommended to proceed using styled-components or CSS, but not both
80
+
81
+ if you proceed with styled-components:
82
+ - remove the single `.css` example in `/src/styles/`
83
+ - that's it!
84
+
85
+ if you prefer CSS:
86
+ - alter `.stylelintrc.js` and `.husky/pre-commit` per the files' notes
87
+ - remove `.ts` files from `/src/styles/` or "recreate" them in `.css`
88
+
89
+ ## environmental settings
90
+
91
+ access environmental variables in code like so
92
+ ```js
93
+ console.log(process.env.PORT)
94
+ ```
95
+
96
+ ### build settings
97
+
98
+ some environmental setting are explicitly set in the npm scripts using `cross-env`
99
+
100
+ - `development` when running the dev server
101
+ - `production` when running the build
102
+
103
+ these variables set the OS env as early as possible and control build tool behavior
104
+
105
+ they are set in the scripts to guarantee consistent, production-safe builds across local, CI, and hosting environments
106
+
107
+ ### `.env` variables
108
+
109
+ add new or alter existing environmental variables via the `.env` file
110
+
111
+ `.env` is intended for application runtime configuration - not build tool configuration
112
+
113
+ the following variables exist in the default configuration and can be altered
114
+
115
+ #### develop (dev server)
116
+ ```
117
+ # optional
118
+ PORT={port number}
119
+ INLINE_SIZE_LIMIT={default is 10000}
120
+ ```
121
+
122
+ #### production (build)
123
+ ```
124
+ # optional
125
+ INLINE_SIZE_LIMIT={default is 10000}
126
+ ```
127
+
128
+ ## dependency overrides
129
+
130
+ this version includes minimal npm `overrides` to patch known transitive vulnerabilities in tooling
131
+
132
+ they are intentionally limited to patch-level upgrades within the same major
133
+
134
+ you can remove them in the future by:
135
+
136
+ 1. running `npm update`
137
+ 2. removing the `overrides` section
138
+ 3. reinstalling dependencies
139
+ 4. running `npm audit`
140
+
141
+
@@ -0,0 +1,116 @@
1
+ #! /usr/bin/env node
2
+ const { writeFile } = require('fs/promises')
3
+ const { execSync } = require('child_process')
4
+ const path = require('path')
5
+ const yargs = require('yargs/yargs')
6
+ const { hideBin } = require('yargs/helpers')
7
+ const packageJson = require('../package.json')
8
+
9
+ const run = async () => {
10
+ const repo = 'https://github.com/daveKontro/create-application-template-rs/tarball/main'
11
+
12
+ const execCommand = (command) => {
13
+ try {
14
+ execSync(command, { stdio: 'inherit' })
15
+ } catch (error) {
16
+ console.error(`${command} failed`, error)
17
+ process.exit(1)
18
+ }
19
+
20
+ return true
21
+ }
22
+
23
+ // consume arguments
24
+ const argv = yargs(hideBin(process.argv)).argv
25
+
26
+ if (!argv.name) {
27
+ console.error('WARNING add a project name like so: npx create-application-template-rs --name={my-project}')
28
+ process.exit(1)
29
+ }
30
+
31
+ const projectPaths = {
32
+ root: path.resolve('.', argv.name),
33
+ get bin() { return path.resolve(this.root, 'bin') },
34
+ get src() { return path.resolve(this.root, 'src') },
35
+ get env() { return path.resolve(this.root, '.env') },
36
+ get packageJson() { return path.resolve(this.root, 'package.json') },
37
+ get subDirFiles() {
38
+ const src = path.resolve(this.root, 'src')
39
+ const assets = path.resolve(src, 'assets')
40
+ const styles = path.resolve(src, 'styles')
41
+ const components = path.resolve(src, 'components')
42
+
43
+ const srcDirs = {
44
+ assets: {
45
+ faviconIco: path.resolve(assets, 'favicon.ico'),
46
+ logoSvg: path.resolve(assets, 'logo.svg'),
47
+ },
48
+ components: {
49
+ appSpecTsx: path.resolve(components, 'App.spec.tsx'),
50
+ appTsx: path.resolve(components, 'App.tsx'),
51
+ },
52
+ styles: {
53
+ logoStyledTs: path.resolve(styles, 'Logo.styled.ts'),
54
+ themeTs: path.resolve(styles, 'theme.ts'),
55
+ },
56
+ }
57
+
58
+ const webpackDirs = {
59
+ webpack: {
60
+ webpackCommonJs:
61
+ path.resolve(this.root, 'webpack', 'webpack.common.js'),
62
+ },
63
+ }
64
+
65
+ const paths = { ...srcDirs, ...webpackDirs }
66
+
67
+ return {
68
+ src: { ...paths },
69
+ }
70
+ },
71
+ }
72
+
73
+ const isNameDotCommand = (argv.name === '.')
74
+ const projectName = isNameDotCommand ? path.basename(process.cwd()) : argv.name
75
+
76
+ console.info('')
77
+ console.info(`Your project name is: ${projectName}`)
78
+ console.info('')
79
+
80
+ // create project
81
+ execCommand(`curl -L ${repo} | tar zx --one-top-level=${argv.name} --strip-components 1`)
82
+
83
+ // groom project
84
+ if (packageJson.hasOwnProperty('name')) packageJson.name = projectName
85
+ if (packageJson.hasOwnProperty('version')) packageJson.version = '1.0.0'
86
+ if (packageJson.hasOwnProperty('description')) packageJson.description = ''
87
+ if (packageJson.hasOwnProperty('author')) packageJson.author = ''
88
+ if (packageJson.hasOwnProperty('bin')) delete packageJson.bin
89
+ if (packageJson.hasOwnProperty('repository')) delete packageJson.repository
90
+ if (packageJson.dependencies.hasOwnProperty('yargs')) delete packageJson.dependencies.yargs
91
+
92
+ execCommand(`rm ${projectPaths.packageJson}`)
93
+ execCommand(`rm -rf ${projectPaths.bin}`)
94
+
95
+ try {
96
+ await writeFile(projectPaths.packageJson, JSON.stringify(packageJson, null, 2), {
97
+ encoding: 'utf8',
98
+ })
99
+ } catch (error) {
100
+ console.error('package.json creation failed', error)
101
+ process.exit(1)
102
+ }
103
+
104
+ execCommand(`touch ${projectPaths.env}`)
105
+
106
+ // install project dependencies
107
+ execCommand(`npm --prefix ${projectPaths.root} install`)
108
+
109
+ // finish up
110
+ console.info('')
111
+ console.info('Thanks for using Create Application Template!')
112
+
113
+ process.exit(0)
114
+ }
115
+
116
+ run()
@@ -0,0 +1,13 @@
1
+ // turning style imports into empty objects
2
+ // https://jestjs.io/docs/code-transformation
3
+
4
+ module.exports = {
5
+ process() {
6
+ return {
7
+ code: 'module.exports = {}',
8
+ }
9
+ },
10
+ getCacheKey() {
11
+ return 'cssTransform'
12
+ },
13
+ }
@@ -0,0 +1,12 @@
1
+ // turning font file imports into empty objects
2
+
3
+ module.exports = {
4
+ process() {
5
+ return {
6
+ code: 'module.exports = {}',
7
+ }
8
+ },
9
+ getCacheKey() {
10
+ return 'fontTransform'
11
+ },
12
+ }
package/jest/setup.js ADDED
@@ -0,0 +1,5 @@
1
+ // make a browser-like environment
2
+
3
+ if (typeof window !== 'undefined') {
4
+ require('whatwg-fetch') // fetch() polyfill
5
+ }