nitro-web 0.0.22 → 0.0.24

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 (47) hide show
  1. package/client/app.tsx +1 -1
  2. package/client/store.ts +1 -1
  3. package/components/auth/reset.tsx +1 -1
  4. package/components/auth/signin.tsx +1 -1
  5. package/components/auth/signup.tsx +1 -1
  6. package/components/partials/element/avatar.tsx +1 -1
  7. package/components/partials/element/message.tsx +1 -1
  8. package/components/partials/form/drop.tsx +1 -1
  9. package/components/partials/form/input.tsx +1 -1
  10. package/components/partials/form/select.tsx +1 -1
  11. package/components/partials/styleguide.tsx +1 -1
  12. package/components/settings/settings-team--member.tsx +1 -1
  13. package/package.json +24 -54
  14. package/semver-updater.cjs +7 -6
  15. package/tsconfig.json +1 -1
  16. package/tsconfig.types.json +15 -0
  17. package/.github/workflows/deploy.yml +0 -36
  18. package/_example/.env +0 -16
  19. package/_example/client/config.ts +0 -2
  20. package/_example/client/css/index.css +0 -35
  21. package/_example/client/fonts/inter-v13-latin-300.woff2 +0 -0
  22. package/_example/client/fonts/inter-v13-latin-500.woff2 +0 -0
  23. package/_example/client/fonts/inter-v13-latin-600.woff2 +0 -0
  24. package/_example/client/fonts/inter-v13-latin-700.woff2 +0 -0
  25. package/_example/client/fonts/inter-v13-latin-800.woff2 +0 -0
  26. package/_example/client/fonts/inter-v13-latin-900.woff2 +0 -0
  27. package/_example/client/fonts/inter-v13-latin-regular.woff2 +0 -0
  28. package/_example/client/imgs/android-chrome-512x512.png +0 -0
  29. package/_example/client/imgs/favicon.png +0 -0
  30. package/_example/client/imgs/logo/logo-white.svg +0 -13
  31. package/_example/client/imgs/logo/logo.svg +0 -13
  32. package/_example/client/index.html +0 -12
  33. package/_example/client/index.ts +0 -9
  34. package/_example/components/auth.api.js +0 -1
  35. package/_example/components/index.tsx +0 -230
  36. package/_example/components/partials/layouts.tsx +0 -52
  37. package/_example/components/settings.api.js +0 -1
  38. package/_example/package.json +0 -112
  39. package/_example/server/config.js +0 -130
  40. package/_example/server/email/welcome.html +0 -27
  41. package/_example/server/index.js +0 -33
  42. package/_example/tailwind.config.js +0 -75
  43. package/_example/tsconfig.json +0 -35
  44. package/_example/types.ts +0 -1
  45. package/_example/webpack.config.js +0 -3
  46. package/readme.md +0 -74
  47. package/webpack.config.js +0 -356
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "downlevelIteration": true,
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "isolatedModules": true,
9
- "jsx": "react-jsx",
10
- "lib": ["es6", "dom", "dom.iterable", "esnext"],
11
- "module": "esnext",
12
- "moduleResolution": "node",
13
- "noEmit": false,
14
- "noFallthroughCasesInSwitch": true,
15
- "noImplicitAny": true,
16
- "noImplicitReturns": false,
17
- "noImplicitThis": true,
18
- "noStrictGenericChecks": false,
19
- "outDir": "./dist",
20
- "paths": {
21
- "types": ["./types.ts"]
22
- },
23
- "resolveJsonModule": true,
24
- "skipLibCheck": true,
25
- "sourceMap": true,
26
- "strict": true,
27
- "target": "es6"
28
- },
29
- "include": [
30
- "client",
31
- "components/**/*.tsx",
32
- "components/**/*.ts",
33
- "types"
34
- ]
35
- }
package/_example/types.ts DELETED
@@ -1 +0,0 @@
1
- export type { Config, Errors, User } from 'nitro-web/types'
@@ -1,3 +0,0 @@
1
- import config from './server/config.js'
2
- import { getConfig } from 'nitro-web/webpack.config.js'
3
- export default getConfig(config)
package/readme.md DELETED
@@ -1,74 +0,0 @@
1
- # Nitro
2
-
3
- [![NPM](https://img.shields.io/npm/v/nitro-web.svg)](https://www.npmjs.com/package/nitro-web)
4
-
5
- Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀
6
-
7
- ```bash
8
- npm i nitro-web
9
- ```
10
-
11
- ### Install
12
-
13
- 1. Copy ./_example into your project
14
- 2. In package.json, replace `"nitro-web": "file:.."` with `"nitro-web": "~0.0.22"`
15
- 3. In package.json, replace `"../.eslintrc.json"` with `"./node_modules/nitro-web/.eslintrc.json"`
16
- 4. Run `npm i`
17
-
18
- ### Usage
19
-
20
- On the client, you can import components and page-components as you would normally. See ./example for further info.
21
-
22
- ```javascript
23
- import { SigninPage, Toggle, util } from 'nitro-web'
24
- ```
25
-
26
- On the server, you can import the express router, default models, and controllers. See ./example for further info.
27
-
28
- ```javascript
29
- import { setupRouter, util } from 'nitro-web/server'
30
- const server = await setupRouter(config)
31
- server.listen(3001, '0.0.0.0')
32
- ```
33
-
34
- ### Run
35
-
36
- ```bash
37
- # Running in development (watching for changes)
38
- npm run dev:server # run and watch the nodemon server
39
- npm run dev:client # run and watch the webpack dev server
40
- npm run dev # or run and watch both the server and client
41
-
42
- # Building for production
43
- npm run build
44
- npm run start
45
- ```
46
-
47
- ### Nitro Development
48
-
49
- The same run commands can be used in ./ which are actually executed in ./example/ via npm workspaces (`-w` flag).
50
-
51
- If util.js is updated, you must run `npm run types` to update the types file.
52
-
53
- ### Versions
54
-
55
- - Express `^4.17`
56
- - Monastery `~3.5.1`
57
- - Node `^18`
58
- - React `^18.3`
59
- - Tailwind `^3.4`
60
- - Webpack `^5.92`
61
-
62
- ### Common packages
63
-
64
- - `pdf-to-img`
65
- - `pdfmake`
66
- - `react-chartjs-2`
67
- - `jest: ^29.7.0`
68
- - `migrate-mongo: ^10.0.0`
69
- - `eslint-plugin-jest: ^28.9.0`
70
-
71
- ### Package notes
72
-
73
- - Added twin.macro is required as a peer dependency to ./.
74
- - Added tailwindcss^3 as a peer dependency to ./ to stop tailwind^4.0.0 from being installed
package/webpack.config.js DELETED
@@ -1,356 +0,0 @@
1
- import axios from '@hokify/axios'
2
- import axiosRetry from 'axios-retry'
3
- import autoprefixer from 'autoprefixer'
4
- import CleanTerminalPlugin from 'clean-terminal-webpack-plugin'
5
- import { CleanWebpackPlugin } from 'clean-webpack-plugin'
6
- import CopyWebpackPlugin from 'copy-webpack-plugin'
7
- import HtmlWebpackPlugin from 'html-webpack-plugin'
8
- import MiniCssExtractPlugin from 'mini-css-extract-plugin'
9
- import webpackNodeExternals from 'webpack-node-externals'
10
- import path from 'path'
11
- // import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
12
- import tailwindcss from 'tailwindcss'
13
- import webpack from 'webpack'
14
- import ESLintPlugin from 'eslint-webpack-plugin'
15
- import postcssImport from 'postcss-import'
16
- import postcssNested from 'postcss-nested'
17
- import postcssFor from 'postcss-for'
18
- import { createRequire } from 'module'
19
- import { getDirectories } from 'nitro-web/util'
20
-
21
- const _require = createRequire(import.meta.url)
22
- const pick = (object, list) => list.reduce((o, e) => ((o[e] = object[e]), o), {})
23
- const isBuild = process.env.NODE_ENV == 'production'
24
-
25
- axiosRetry(axios, {
26
- retries: 10,
27
- retryDelay: () => 150,
28
- retryCondition: (e) => e.code == 'ECONNREFUSED',
29
- })
30
-
31
- // process.traceDeprecation = true
32
- export const getConfig = (config) => {
33
- const { clientDir, componentsDir, distDir, imgsDir } = getDirectories(path, config.pwd)
34
- const publicPath = getPublicPath(config.env, config.homepage, config.publicPath)
35
-
36
- return (env, argv) => [{
37
- devtool: isBuild ? false : 'source-map',
38
- entry: clientDir + 'index.ts',
39
- // entry: isBuild ? './client/index.tsx' : ['webpack-plugin-serve/client', './client/index.tsx'], // check this
40
- mode: isBuild ? 'production' : 'development',
41
- // target=node ignores node_modules
42
- externals: argv.target?.[0] == 'node' ? [webpackNodeExternals()] : [],
43
- // target=node ignores builtin modules
44
- target: argv.target?.[0] || 'web',
45
- devServer: {
46
- // needed when connecting to the devserver through a domain
47
- allowedHosts: 'all',
48
- client: {
49
- logging: 'warn', // 'info'
50
- overlay: true,
51
- },
52
- compress: false,
53
- devMiddleware: {
54
- writeToDisk: false,
55
- },
56
- historyApiFallback: true,
57
- host: '0.0.0.0',
58
- hot: true,
59
- port: 3000,
60
- proxy: {
61
- '/api': {
62
- logLevel: 'silent',
63
- target: 'http://0.0.0.0:3001',
64
- // bypass: async function (req, res, proxyOptions) {
65
- // // // wait for pong, indicating express has restarted
66
- // // // all non-asset routes are triggered (even the main page)
67
- // // // another method: https://codeburst.io/dont-use-nodemon-there-are-better-ways-fc016b50b45e
68
- // // if (!req.url.match(/^\/api\//)) return
69
- // // await axios.get('http://0.0.0.0:3001/ping')
70
- // },
71
- },
72
- '/server/email/templates': {
73
- logLevel: 'silent',
74
- target: 'http://0.0.0.0:3001',
75
- },
76
- },
77
- },
78
- infrastructureLogging: {
79
- level: 'info',
80
- // debug: [(name) => !name.match(/webpack-dev-server/)],
81
- // console: (a, b, c) => { // webpack v5.3.1
82
- // console.log(1, a, b, c)
83
- // },
84
- },
85
- module: {
86
- rules: [
87
- {
88
- test: /\.css$/,
89
- use: [
90
- { loader: MiniCssExtractPlugin.loader },
91
- { loader: 'css-loader', options: { sourceMap: true } },
92
- { loader: 'postcss-loader', options: {
93
- postcssOptions: {
94
- plugins: [
95
- postcssImport,
96
- // postcssImport({
97
- // resolve: postcssImportResolver({
98
- // alias: {
99
- // 'nitro-web/client/css/components.css': path.resolve(nitroDir, 'client/css/components.css'),
100
- // 'nitro-web/client/css/fonts.css': path.resolve(nitroDir, 'client/css/fonts.css'),
101
- // },
102
- // }),
103
- // }),
104
- postcssNested,
105
- postcssFor,
106
- tailwindcss({ config: path.resolve(config.pwd, 'tailwind.config.js') }),
107
- autoprefixer,
108
- ],
109
- },
110
- sourceMap: true,
111
- }},
112
- ],
113
- },
114
- {
115
- test: /\.(m?js|jsx|ts|tsx)$/,
116
- exclude: (
117
- (path) => {
118
- // Dont transpile node modules except for date-fns, which uses ES6
119
- return path.includes('node_modules')
120
- && !path.includes('node_modules/date-fns')
121
- && !path.includes('node_modules/nitro-web')
122
- }
123
- ),
124
- use: [
125
- {
126
- loader: 'babel-loader',
127
- options: {
128
- presets: [
129
- ['@babel/preset-env', { debug: false }],
130
- ['@babel/preset-typescript', { allowNamespaces: true }],
131
- ['@babel/preset-react', { runtime: 'automatic', importSource: '@emotion/react', development: !isBuild }],
132
- ],
133
- plugins: [
134
- 'react-html-attrs',
135
- '@babel/plugin-syntax-dynamic-import',
136
- '@babel/plugin-transform-runtime',
137
- '@emotion/babel-plugin',
138
- // Below allows us to reference tailwindcss theme variables in emotion blocks
139
- // https://github.com/ben-rogerson/twin.macro/blob/master/docs/options.md
140
- // https://medium.com/fredwong-it/emotion-tailwind-twin-macro-7fdc5f2ae5f9
141
- // https://github.com/ben-rogerson/twin.examples/tree/master/react-emotion-typescript#complete-the-typescript-setup
142
- ['babel-plugin-macros', {
143
- 'twin': {
144
- preset: 'emotion',
145
- config: path.resolve(config.pwd, 'tailwind.config.js'),
146
- },
147
- }],
148
- // 'react-refresh/babel', // !isBuild && _require.resolve('react-refresh/babel'),
149
- ].filter(Boolean),
150
- },
151
- },
152
- ],
153
- },
154
- {
155
- // Workaround to hide emotion's pseudo console noise (bug)
156
- // https://github.com/emotion-js/emotion/issues/1105#issuecomment-547247291
157
- test: /node_modules\/@emotion\/cache\/(src|dist)/,
158
- loader: 'string-replace-loader',
159
- options: {
160
- search: 'if (unsafePseudoClasses',
161
- replace: 'if (false && unsafePseudoClasses',
162
- },
163
- },
164
- {
165
- test: /\.csv$/,
166
- use: [
167
- {
168
- loader: 'csv-loader',
169
- options: {
170
- delimiter: ',',
171
- header: true,
172
- skipEmptyLines: true,
173
- },
174
- },
175
- ],
176
- },
177
- {
178
- test: /\.(png|jpe?g|gif|woff|woff2|ttf|eot)$/i,
179
- type: 'asset/resource',
180
- generator: {
181
- filename: 'assets/images/[name].[ext][query]',//[hash][ext][query]
182
- },
183
- },
184
- {
185
- test: /\.svg$/,
186
- use: [
187
- {
188
- loader: '@svgr/webpack',
189
- options: {
190
- svgoConfig: {
191
- plugins: [
192
- {
193
- name: 'preset-default',
194
- params: {
195
- overrides: {
196
- removeViewBox: false,
197
- convertPathData: false,
198
- cleanupNumericValues: false,
199
- convertShapeToPath: false,
200
- },
201
- },
202
- },
203
- // 'removeDimensions', (dont need this, just use width/height={undefined} if required)
204
- // {
205
- // name: 'addClassesToSVGElement',
206
- // params: {
207
- // className: (node, info) => {
208
- // console.log(info)
209
- // return `svg-${info?.path?.split('.')[0]}`
210
- // },
211
- // },
212
- // },
213
- {
214
- // until svgr updated to svgo@4 for addClassesToSVGElement fns support
215
- name: 'add-data-id-to-svg-icons',
216
- fn: (root, _params, info) => {
217
- const { basename } = info.path.match(/.*\/(?<basename>.*)\.svg$/).groups
218
- if (root.children[0].name === 'svg') {
219
- root.children[0].attributes.className = `svg-${basename}`
220
- }
221
- },
222
- },
223
- ],
224
- },
225
- },
226
- },
227
- ],
228
- },
229
- ],
230
- },
231
- node: {
232
- __filename: true,
233
- },
234
- output: {
235
- // devtoolModuleFilenameTemplate: (info) => {
236
- // // DevTools doesn't link webpack:// sourcemap filepaths, force file://.
237
- // let path = 'file://' + encodeURI(info.absoluteResourcePath)
238
- // // React only: append ?2 to all paths so devtools can link to the CSS-in-JS
239
- // if (path.match(/\.jsx$/)) return path + '?2'
240
- // // Vue only: fix Vue:CSS paths
241
- // else return path.replace(/(\/components\/).*?components\//, '$1')
242
- // },
243
- // We are outputing assets into a handy subdir to allow for easier asset cache control. We can't
244
- // simply use `path` because webpack-dev-server won't work when writeFiles=false (in memory).
245
- // Because of this we manually need to prefix all output filenames with `assets/`.
246
- filename: `assets/bundle.[name]${isBuild ? '.[contenthash]' : ''}.js`,
247
- path: distDir,
248
- publicPath: publicPath,
249
- },
250
- performance: {
251
- hints: false,
252
- },
253
- optimization: {
254
- // Split chunks into seperate emitted assets
255
- splitChunks: {
256
- cacheGroups: {
257
- vendor: {
258
- test: /[\\/]node_modules[\\/].*\.js/,
259
- name: 'vendor',
260
- chunks: 'all',
261
- },
262
- },
263
- },
264
- minimize: isBuild,
265
- },
266
- plugins: [
267
- // new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)(),
268
- new CleanWebpackPlugin(),
269
- new CopyWebpackPlugin({
270
- patterns: [
271
- { from: imgsDir + 'favicon.png', to: './favicon.png' },
272
- { from: imgsDir, to: './assets/imgs' },
273
- ],
274
- }),
275
- new webpack.DefinePlugin({
276
- ISDEMO: !!process.env.isDemo,
277
- INJECTED: JSON.stringify({
278
- ...pick(config, config.inject ? config.inject.split(' ') : []),
279
- }),
280
- }),
281
- new ESLintPlugin({
282
- extensions: ['js', 'mjs', 'jsx'],
283
- exclude: ['node_modules'],
284
- }),
285
- new MiniCssExtractPlugin({ filename: `assets/bundle.[name]${isBuild ? '.[contenthash]' : ''}.css` }),
286
- new HtmlWebpackPlugin({ template: clientDir + 'index.html', filename: distDir + 'index.html' }),
287
- new InterpolateHtmlPlugin(HtmlWebpackPlugin, { PUBLIC_PATH: publicPath, NAME: config.name }),
288
- new CleanTerminalPlugin({ skipFirstRun: true }),
289
- // !isBuild && new ReactRefreshWebpackPlugin({ overlay: false }),
290
- ].filter(Boolean),
291
- resolve: {
292
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
293
- // fallback: { fs: false },
294
- alias: {
295
- // required for auto-importing page components into nitro app.js router
296
- 'componentsDir': componentsDir,
297
- },
298
- },
299
- stats: {
300
- all: false,
301
- assets: !process.env.WEBPACK_SERVE,
302
- errors: true,
303
- errorDetails: true,
304
- timings: !process.env.WEBPACK_SERVE,
305
- warnings: true,
306
- },
307
- watchOptions: {
308
- aggregateTimeout: 50,
309
- ignored: new RegExp(`(${componentsDir}.*\\.api\\.js$|node_modules/(?!cherry))`),
310
- },
311
- }]
312
- }
313
-
314
- class InterpolateHtmlPlugin {
315
- constructor(htmlWebpackPlugin, replacements) {
316
- this.htmlWebpackPlugin = htmlWebpackPlugin
317
- this.replacements = replacements
318
- }
319
- apply(compiler) {
320
- compiler.hooks.compilation.tap('InterpolateHtmlPlugin', compilation => {
321
- this.htmlWebpackPlugin
322
- .getHooks(compilation)
323
- .afterTemplateExecution.tap('InterpolateHtmlPlugin', data => {
324
- // Run HTML through a series of user-specified string replacements.
325
- for (const key in this.replacements) {
326
- const value = this.replacements[key]
327
- data.html = data.html.replace(
328
- new RegExp('{' + key + '}', 'g'),
329
- value
330
- )
331
- }
332
- })
333
- })
334
- }
335
- }
336
-
337
- function getPublicPath(env, homepage, publicPath) {
338
- /**
339
- * Returns public path used for webapck (we can't use relative paths)
340
- * @param {string} env - 'development', 'staging', 'production'
341
- * @param {string} publicPath - proces.env.publicPath
342
- * @param {string} homepage - package.json homepage
343
- */
344
- if (publicPath) {
345
- const publicPathObj = new URL(publicPath, 'https://domain.com')
346
- return publicPathObj.pathname
347
-
348
- } else if (homepage) {
349
- const homepageObj = new URL(homepage, 'https://domain.com')
350
- if (env === 'development') return '/'
351
- else return homepageObj.pathname
352
-
353
- } else {
354
- return '/'
355
- }
356
- }