proteum 1.0.0-1 → 1.0.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/changelog.md +5 -0
  2. package/client/components/Dialog/index.less +1 -3
  3. package/package.json +3 -69
  4. package/server/app/container/console/index.ts +1 -1
  5. package/templates/composant.tsx +40 -0
  6. package/templates/form.ts +30 -0
  7. package/templates/modal.tsx +47 -0
  8. package/templates/modele.ts +56 -0
  9. package/templates/page.tsx +74 -0
  10. package/templates/route.ts +43 -0
  11. package/templates/service.ts +75 -0
  12. package/tsconfig.common.json +1 -2
  13. package/vscode/copyimportationpath/.eslintrc.json +24 -0
  14. package/vscode/copyimportationpath/.vscodeignore +12 -0
  15. package/vscode/copyimportationpath/CHANGELOG.md +9 -0
  16. package/vscode/copyimportationpath/README.md +3 -0
  17. package/vscode/copyimportationpath/copyimportationpath-0.0.1.vsix +0 -0
  18. package/vscode/copyimportationpath/out/extension.js +206 -0
  19. package/vscode/copyimportationpath/out/extension.js.map +1 -0
  20. package/vscode/copyimportationpath/package-lock.json +4536 -0
  21. package/vscode/copyimportationpath/package.json +86 -0
  22. package/vscode/copyimportationpath/src/extension.ts +300 -0
  23. package/vscode/copyimportationpath/tsconfig.json +22 -0
  24. package/vscode/copyimportationpath/vsc-extension-quickstart.md +42 -0
  25. package/cli/app/config.ts +0 -54
  26. package/cli/app/index.ts +0 -195
  27. package/cli/bin.js +0 -11
  28. package/cli/commands/build.ts +0 -34
  29. package/cli/commands/deploy/app.ts +0 -29
  30. package/cli/commands/deploy/web.ts +0 -60
  31. package/cli/commands/dev.ts +0 -109
  32. package/cli/commands/init.ts +0 -85
  33. package/cli/compiler/client/identite.ts +0 -72
  34. package/cli/compiler/client/index.ts +0 -334
  35. package/cli/compiler/common/babel/index.ts +0 -170
  36. package/cli/compiler/common/babel/plugins/index.ts +0 -0
  37. package/cli/compiler/common/babel/plugins/services.ts +0 -579
  38. package/cli/compiler/common/babel/routes/imports.ts +0 -127
  39. package/cli/compiler/common/babel/routes/routes.ts +0 -1130
  40. package/cli/compiler/common/files/autres.ts +0 -39
  41. package/cli/compiler/common/files/images.ts +0 -35
  42. package/cli/compiler/common/files/style.ts +0 -78
  43. package/cli/compiler/common/index.ts +0 -154
  44. package/cli/compiler/index.ts +0 -532
  45. package/cli/compiler/server/index.ts +0 -211
  46. package/cli/index.ts +0 -189
  47. package/cli/paths.ts +0 -165
  48. package/cli/print.ts +0 -12
  49. package/cli/tsconfig.json +0 -38
  50. package/cli/utils/index.ts +0 -22
  51. package/cli/utils/keyboard.ts +0 -78
@@ -1,211 +0,0 @@
1
- /*----------------------------------
2
- - DEPENDANCES
3
- ----------------------------------*/
4
-
5
- // Npm
6
- import webpack from 'webpack';
7
- import fs from 'fs-extra';
8
-
9
- // Minimizers
10
- const TerserPlugin = require("terser-webpack-plugin");
11
- //var VirtualModulesPlugin = require('webpack-virtual-modules');
12
-
13
- // Core
14
- import cli from '@cli';
15
- import createCommonConfig, { TCompileMode, regex } from '../common';
16
-
17
- // Type
18
- import type { App } from '../../app';
19
-
20
- /*const getCorePluginsList = (app: App,) => {
21
-
22
- const corePlugins: string[] = [];
23
-
24
- if (fs.existsSync( app.paths.root + '/node_modules' ))
25
- for (const moduleName of fs.readdirSync( app.paths.root + '/node_modules' ))
26
- if (moduleName.startsWith('proteum'))
27
- corePlugins.push(app.paths.root + '/node_modules/' + moduleName + '/src');
28
-
29
- if (fs.existsSync( cli.paths.core.root + '/node_modules' ))
30
- for (const moduleName of fs.readdirSync( cli.paths.core.root+ '/node_modules' ))
31
- if (moduleName.startsWith('proteum'))
32
- corePlugins.push(cli.paths.core.root + '/node_modules/' + moduleName + '/src');
33
-
34
- return corePlugins;
35
- }*/
36
-
37
- const debug = false;
38
-
39
- /*----------------------------------
40
- - CONFIG
41
- ----------------------------------*/
42
- export default function createCompiler( app: App, mode: TCompileMode ): webpack.Configuration {
43
-
44
- debug && console.info(`Creating compiler for server (${mode}).`);
45
- const dev = mode === 'dev';
46
-
47
- const commonConfig = createCommonConfig(app, 'server', mode);
48
- const { aliases } = app.aliases.server.forWebpack({
49
- modulesPath: app.paths.root + '/node_modules'
50
- });
51
-
52
- // We're not supposed in any case to import client services from server
53
- delete aliases["@client/services"];
54
- delete aliases["@/client/services"];
55
-
56
- debug && console.log(`[${mode}] node_modules dirs:`, commonConfig.resolveLoader?.modules,
57
- '\nModule aliases for webpack:', aliases);
58
- const config: webpack.Configuration = {
59
-
60
- ...commonConfig,
61
-
62
- name: 'server',
63
- target: 'node',
64
- entry: {
65
- server: [
66
- cli.paths.coreRoot + '/server/index.ts'
67
- ],
68
- },
69
-
70
- output: {
71
-
72
- pathinfo: dev,
73
-
74
- libraryTarget: 'commonjs2',
75
-
76
- path: app.paths.bin,
77
- filename: '[name].js',
78
- publicPath: '/',
79
- assetModuleFilename: 'public/[hash][ext]',
80
-
81
- chunkFilename: 'chunks/[name].js',
82
- // HMR
83
- hotUpdateMainFilename: 'updates/[fullhash].hot-update.json',
84
- hotUpdateChunkFilename: 'updates/[id].[fullhash].hot-update.js',
85
-
86
- },
87
-
88
- externalsPresets: { node: true }, // in order to ignore built-in modules like path, fs, etc.
89
- externals: [
90
-
91
- './chunk-manifest.json',
92
- './asset-manifest.json',
93
-
94
- // node_modules
95
- function ({ request }, callback) {
96
-
97
- const shouldCompile = request !== undefined && (
98
- // Local files
99
- request[0] === '.' || request[0] === '/'
100
- ||
101
- // Aliased modules
102
- app.aliases.server.containsAlias(request)
103
- ||
104
- // TODO: proteum.conf: compile: include
105
- // Compile proteum modules
106
- request.startsWith('proteum')
107
- ||
108
- // Compile 5HTP modules
109
- request.startsWith('react-number-format') ||
110
- request.startsWith('@floating-ui')
111
- )
112
-
113
- //console.log('isNodeModule', request, isNodeModule);
114
-
115
- if (!shouldCompile) {
116
-
117
- // Externalize to a commonjs module using the request path
118
- return callback(undefined, 'commonjs ' + request);
119
- }
120
-
121
- // Continue without externalizing the import
122
- callback();
123
- },
124
- ],
125
-
126
- resolve: {
127
-
128
- ...commonConfig.resolve,
129
-
130
- alias: aliases,
131
-
132
- extensions: ['.ts', '.tsx', ".json", ".sql", ".js"],
133
- },
134
-
135
- module: {
136
- // Make missing exports an error instead of warning
137
- strictExportPresence: true,
138
-
139
- rules: [
140
- {
141
- test: regex.scripts,
142
- include: [
143
-
144
- app.paths.root + '/client',
145
- cli.paths.core.root + '/client',
146
-
147
- app.paths.root + '/common',
148
- cli.paths.core.root + '/common',
149
-
150
- // Dossiers server uniquement pour le bundle server
151
- app.paths.root + '/server',
152
- cli.paths.core.root + '/server',
153
-
154
- // Complle 5HTP modules so they can refer to the framework instance and aliases
155
- // Temp disabled because compile issue on vercel
156
- //...getCorePluginsList(app)
157
- ],
158
- rules: require('../common/babel')(app, 'server', dev)
159
- },
160
-
161
- // Les pages étan tà la fois compilées dans le bundle client et serveur
162
- // On ne compile les ressources (css) qu'une seule fois (coté client)
163
- {
164
- test: regex.style,
165
- loader: 'null-loader'
166
- },
167
-
168
- ...require('../common/files/images')(app, dev, false),
169
-
170
- ...require('../common/files/autres')(app, dev, false),
171
-
172
- // Exclude dev modules from production build
173
- /*...(dev ? [] : [
174
- {
175
- test: app.paths.root + '/node_modules/react-deep-force-update/lib/index.js'),
176
- loader: 'null-loader',
177
- },
178
- ]),*/
179
- ],
180
- },
181
-
182
- plugins: [
183
-
184
- ...(commonConfig.plugins || [])
185
- ],
186
-
187
- optimization: {
188
- minimizer: dev ? [] : [
189
- new TerserPlugin({
190
- terserOptions: {
191
- // Consere les classnames
192
- //keep_classnames: true,
193
- //keep_fnames: true,
194
- }
195
- }),
196
- ]
197
- },
198
-
199
- // https://webpack.js.org/configuration/devtool/#devtool
200
- devtool: dev
201
- ? 'eval-source-map' // Recommended choice for development builds with high quality SourceMaps.
202
- : 'source-map', // Recommended choice for production builds with high quality SourceMaps.
203
-
204
- // eval-source-map n'est pas précis
205
- /*devServer: {
206
- hot: true,
207
- },*/
208
- };
209
-
210
- return config;
211
- };
package/cli/index.ts DELETED
@@ -1,189 +0,0 @@
1
- #!/usr/bin/env -S npx ts-node
2
-
3
- process.traceDeprecation = true;
4
-
5
- /*----------------------------------
6
- - DEPENDANCES
7
- ----------------------------------*/
8
-
9
- // Npm
10
- import fs from 'fs-extra';
11
- import cp from 'child_process';
12
-
13
- // Libs
14
- import Paths from './paths';
15
-
16
- /*----------------------------------
17
- - TYPES
18
- ----------------------------------*/
19
-
20
- type TCliCommand = () => Promise<{
21
- run: () => Promise<void>
22
- }>
23
-
24
- type TArgsObject = {
25
- [key: string]: string | boolean | string[]
26
- }
27
-
28
- /*----------------------------------
29
- - CLASSE
30
- ----------------------------------*/
31
- /*
32
- IMPORTANT: The CLI must be independant of the app instance and libs
33
- */
34
- export class CLI {
35
-
36
- // Context
37
- public args: TArgsObject = {};
38
-
39
- public debug: boolean = false;
40
-
41
- public packageJson: {[key: string]: any};
42
-
43
- public constructor(
44
- public paths = new Paths( process.cwd() )
45
- ) {
46
- this.debug && console.log(`[cli] 5HTP CLI`, process.env.npm_package_version);
47
-
48
- this.debug && console.log(`[cli] Apply aliases ...`);
49
- this.paths.applyAliases();
50
-
51
- this.packageJson = this.loadPkg();
52
-
53
- this.start();
54
- }
55
-
56
- /*----------------------------------
57
- - COMMANDS
58
- ----------------------------------*/
59
- // Les importations asynchrones permettent d'accéder à l'instance de cli via un import
60
- // WARN: We load commands asynchonously, so the aliases are applied before the file is imported
61
- public commands: { [name: string]: TCliCommand } = {
62
- "init": () => import('./commands/init'),
63
- "dev": () => import('./commands/dev'),
64
- "build": () => import('./commands/build'),
65
- }
66
-
67
- private loadPkg() {
68
- return fs.readJSONSync(this.paths.core.root + '/package.json');
69
- }
70
-
71
- public start() {
72
-
73
- const [, , commandName, ...argv] = process.argv;
74
-
75
- if (this.commands[commandName] === undefined)
76
- throw new Error(`Command ${commandName} does not exists.`);
77
-
78
- this.args.workdir = process.cwd();
79
-
80
- let opt: string | null = null;
81
- for (const a of argv) {
82
-
83
- if (a[0] === '-') {
84
-
85
- opt = a.substring(1);
86
- if (!(opt in this.args))
87
- throw new Error(`Unknown option: ${opt}`);
88
-
89
- // Init with default value
90
- if (typeof this.args[opt] === "boolean")
91
- this.args[opt] = true;
92
-
93
- } else if (opt !== null) {
94
-
95
- const curVal = this.args[opt];
96
-
97
- if (Array.isArray( curVal ))
98
- curVal.push(a);
99
- else
100
- this.args[opt] = a;
101
-
102
- opt = null;
103
-
104
- } else {
105
-
106
- this.args[ a ] = true;
107
-
108
- }
109
- }
110
-
111
- this.runCommand(commandName);
112
- }
113
-
114
- public async runCommand(command: string) {
115
-
116
- this.debug && console.info(`Running command ${command}`, this.args);
117
-
118
- // Check existance
119
- if (this.commands[command] === undefined)
120
- throw new Error(`Command ${command} does not exists.`);
121
-
122
- const runner = await this.commands[command]();
123
-
124
- // Running
125
- runner.run().then(() => {
126
-
127
- this.debug && console.info(`Command ${command} finished.`);
128
-
129
- }).catch((e) => {
130
-
131
- console.error(`Error during execution of ${command}:`, e);
132
-
133
- }).finally(() => {
134
-
135
- process.exit(0);
136
-
137
- })
138
- }
139
-
140
-
141
- public shell(...commands: string[]) {
142
-
143
- return new Promise<void>(async (resolve) => {
144
-
145
- const fullCommand = commands.map(command => {
146
-
147
- command = command.trim();
148
-
149
- if (command.endsWith(';'))
150
- command = command.substring(0, command.length - 1);
151
-
152
- return command;
153
-
154
- }).join(';');
155
-
156
- console.log('$ ' + fullCommand);
157
-
158
- /*const tempFile = this.paths.app.root + '/.exec.sh';
159
- fs.outputFileSync(tempFile, '#! /bin/bash\n' + fullCommand);
160
- const wrappedCommand = `tilix --new-process -e bash -c 'chmod +x "${tempFile}"; "${tempFile}"; echo "Entrée pour continuer"; read a;'`;*/
161
- const wrappedCommand = `bash -c '${fullCommand}'`;
162
- console.log("Running command: " + wrappedCommand)
163
- //await this.waitForInput('enter');
164
-
165
- const proc = cp.spawn(wrappedCommand, [], {
166
- cwd: process.cwd(),
167
- detached: false,
168
- // Permer de lancer les commandes via des chaines pures (autrement, il faut separer chaque arg dans un tableau)
169
- // https://stackoverflow.com/questions/23487363/how-can-i-parse-a-string-into-appropriate-arguments-for-child-process-spawn
170
- shell: true
171
- });
172
-
173
- console.log( proc.exitCode );
174
-
175
- proc.on('exit', function () {
176
-
177
- //fs.removeSync(tempFile);
178
-
179
- console.log("Command finished.");
180
- resolve();
181
- })
182
-
183
- });
184
-
185
- }
186
-
187
- }
188
-
189
- export default new CLI()
package/cli/paths.ts DELETED
@@ -1,165 +0,0 @@
1
- /*----------------------------------
2
- - DEPENDANCES
3
- ----------------------------------*/
4
-
5
- // Npm
6
- import fs from 'fs';
7
- import path from 'path';
8
- import TsAlias from 'ts-alias';
9
- import moduleAlias from 'module-alias';
10
- import { filenameToImportName } from 'babel-plugin-glob-import';
11
-
12
- // Core
13
-
14
- /*----------------------------------
15
- - TYPES
16
- ----------------------------------*/
17
-
18
- import type { App } from './app';
19
- import type { TAppSide } from './app';
20
-
21
- export type TPathInfosOptions = {
22
- basePath?: string,
23
- shortenExtensions: string[],
24
- // Indexed will be trimed only when the extension can be shorten
25
- trimIndex: boolean,
26
- }
27
-
28
- export type TPathInfos = {
29
-
30
- original: string,
31
- absolute: string,
32
- relative: string,
33
- //forImport: string,
34
-
35
- name: string,
36
- extension: string,
37
- isIndex: boolean
38
- }
39
-
40
- /*----------------------------------
41
- - CONFIG
42
- ----------------------------------*/
43
-
44
- export const staticAssetName = /*isDebug ? '[name].[ext].[hash:8]' :*/ '[hash:8][ext]';
45
-
46
- const pathInfosDefaultOpts = {
47
- shortenExtensions: ['ts', 'js', 'tsx', 'jsx'],
48
- trimIndex: true,
49
- }
50
-
51
- const resolveCoreRoot = (appRoot: string) => {
52
- const localInstall = path.join(appRoot, 'node_modules', 'proteum');
53
- if (fs.existsSync(localInstall)) return localInstall;
54
-
55
- // When running `npx`/global installs, there may be no local `node_modules/proteum` yet.
56
- // Fall back to the installed package root (this file lives in `<root>/cli`).
57
- return path.resolve(__dirname, '..');
58
- }
59
-
60
- /*----------------------------------
61
- - LIB
62
- ----------------------------------*/
63
- export default class Paths {
64
-
65
- /*----------------------------------
66
- - LISTE
67
- ----------------------------------*/
68
-
69
- public constructor(
70
- public appRoot: string,
71
- public coreRoot = resolveCoreRoot(appRoot)
72
- ) {
73
-
74
- }
75
-
76
- public core = {
77
- cli: path.resolve(__dirname, '.'),
78
- root: this.coreRoot,
79
- pages: this.coreRoot + '/client/pages',
80
- }
81
-
82
- /*----------------------------------
83
- - EXTRACTION
84
- ----------------------------------*/
85
-
86
- public infos(filename: string, givenOpts: Partial<TPathInfosOptions> = {}): TPathInfos {
87
-
88
- const opts: TPathInfosOptions = { ...pathInfosDefaultOpts, ...givenOpts }
89
-
90
- // Extraction élements du chemin
91
- const decomp = filename.split('/')
92
- let [nomFichier, extension] = (decomp.pop() as string).split('.');
93
- const shortenExtension = opts.shortenExtensions && opts.shortenExtensions.includes(extension);
94
-
95
- // Vire l'index
96
- const isIndex = nomFichier === 'index'
97
- let cheminAbsolu: string;
98
- let nomReel: string;
99
- if (isIndex && shortenExtension && opts.trimIndex) {
100
- cheminAbsolu = decomp.join('/');
101
- nomReel = decomp.pop() as string;
102
- } else {
103
- cheminAbsolu = [...decomp, nomFichier].join('/')
104
- nomReel = nomFichier
105
- }
106
-
107
- // Conserve l'extension si nécessaire
108
- if (!shortenExtension)
109
- cheminAbsolu += '.' + extension;
110
-
111
- const relative = opts.basePath === undefined
112
- ? ''
113
- : cheminAbsolu.substring( opts.basePath.length + 1 )
114
-
115
- // Retour
116
- const retour = {
117
-
118
- original: filename,
119
- absolute: cheminAbsolu,
120
- relative,
121
-
122
- // Not used anymore, but can be useful in the future
123
- //forImport: this.withAlias(cheminAbsolu, side),
124
-
125
- name: nomReel,
126
- extension,
127
- isIndex
128
- }
129
-
130
- return retour;
131
- }
132
-
133
- public getPageChunk( app: App, file: string ) {
134
-
135
- const infos = this.infos( file, {
136
- basePath: file.startsWith( app.paths.pages ) ? app.paths.pages : this.core.pages,
137
- // Avoid potential conflicts between /landing.tsx and /landing/index.tsx
138
- trimIndex: false,
139
- });
140
-
141
- const filepath = infos.relative;
142
-
143
- // Before: /home/.../src/client/pages/landing/index.tsx
144
- // After: landing
145
- let chunkId = filenameToImportName(filepath);
146
-
147
- // nsure it's non-empty
148
- if (chunkId.length === 0) // = /index.tsx
149
- chunkId = "main";
150
-
151
- return { filepath, chunkId }
152
-
153
- }
154
-
155
- public applyAliases() {
156
-
157
- const aliases = new TsAlias({
158
- rootDir: this.core.cli
159
- });
160
-
161
- //console.log('Applying Aliases ...', aliases.forModuleAlias());
162
- moduleAlias.addAliases( aliases.forModuleAlias() );
163
-
164
- }
165
- }
package/cli/print.ts DELETED
@@ -1,12 +0,0 @@
1
- export const h1 = (titre: string) => console.log(
2
- '\n' +
3
- '######################################################\n' +
4
- '# ' + titre.toUpperCase() + '\n' +
5
- '######################################################'
6
- );
7
-
8
- export const h2 = (titre: string) => console.log(
9
- '------------------------------------------------------\n' +
10
- '> ' + titre.toUpperCase() + '\n' +
11
- '------------------------------------------------------'
12
- );
package/cli/tsconfig.json DELETED
@@ -1,38 +0,0 @@
1
- {
2
- "compilerOptions": {
3
-
4
-
5
- "esModuleInterop": true,
6
- "skipLibCheck": true,
7
- "allowJs": true,
8
- "strict": false,
9
- "downlevelIteration": true,
10
-
11
- // Equivalent webpack: resolve.symblinks = false
12
- "preserveSymlinks": true,
13
- // Décorateurs
14
- "experimentalDecorators": true,
15
-
16
- // React
17
- "jsx": "react-jsx",
18
- "jsxImportSource": "preact",
19
-
20
- "strictPropertyInitialization": true,
21
- "strictNullChecks": true,
22
-
23
- "baseUrl": "./",
24
- "outDir": "./bin",
25
-
26
- "paths": {
27
- "@cli/*": [ "./*" ],
28
- "@cli/app": [ "./app" ],
29
- "@cli": [ "./" ]
30
- },
31
- },
32
-
33
- "ts-node": {
34
- "transpileOnly": true,
35
- },
36
-
37
- "include": ["./"]
38
- }
@@ -1,22 +0,0 @@
1
- /*----------------------------------
2
- - DEPENDANCES
3
- ----------------------------------*/
4
-
5
- // Npm
6
- import fs from 'fs-extra';
7
- import path from 'path';
8
-
9
-
10
- /*----------------------------------
11
- - TYPES
12
- ----------------------------------*/
13
-
14
-
15
- /*----------------------------------
16
- - UTILS
17
- ----------------------------------*/
18
-
19
- export const api = (method: string, path: string, data: object, local: boolean = false) =>
20
- `curl -X ${method} ${local ? 'http://localhost:3010' : 'https://dopamyn.io'}${path} ` +
21
- `-H 'Content-Type: application/json' -H 'Accept: application/json' ` +
22
- `-d '${JSON.stringify(data)}';`;