proteum 1.0.0-1
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/.dockerignore +10 -0
- package/Rte.zip +0 -0
- package/cli/app/config.ts +54 -0
- package/cli/app/index.ts +195 -0
- package/cli/bin.js +11 -0
- package/cli/commands/build.ts +34 -0
- package/cli/commands/deploy/app.ts +29 -0
- package/cli/commands/deploy/web.ts +60 -0
- package/cli/commands/dev.ts +109 -0
- package/cli/commands/init.ts +85 -0
- package/cli/compiler/client/identite.ts +72 -0
- package/cli/compiler/client/index.ts +334 -0
- package/cli/compiler/common/babel/index.ts +170 -0
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +579 -0
- package/cli/compiler/common/babel/routes/imports.ts +127 -0
- package/cli/compiler/common/babel/routes/routes.ts +1130 -0
- package/cli/compiler/common/files/autres.ts +39 -0
- package/cli/compiler/common/files/images.ts +35 -0
- package/cli/compiler/common/files/style.ts +78 -0
- package/cli/compiler/common/index.ts +154 -0
- package/cli/compiler/index.ts +532 -0
- package/cli/compiler/server/index.ts +211 -0
- package/cli/index.ts +189 -0
- package/cli/paths.ts +165 -0
- package/cli/print.ts +12 -0
- package/cli/tsconfig.json +38 -0
- package/cli/utils/index.ts +22 -0
- package/cli/utils/keyboard.ts +78 -0
- package/client/app/component.tsx +54 -0
- package/client/app/index.ts +142 -0
- package/client/app/service.ts +34 -0
- package/client/app.tsconfig.json +28 -0
- package/client/components/Button.tsx +298 -0
- package/client/components/Dialog/Manager.tsx +309 -0
- package/client/components/Dialog/card.tsx +208 -0
- package/client/components/Dialog/index.less +151 -0
- package/client/components/Dialog/status.less +176 -0
- package/client/components/Dialog/status.tsx +48 -0
- package/client/components/index.ts +2 -0
- package/client/components/types.d.ts +3 -0
- package/client/data/input.ts +32 -0
- package/client/global.d.ts +5 -0
- package/client/hooks.ts +22 -0
- package/client/index.ts +6 -0
- package/client/pages/_layout/index.less +6 -0
- package/client/pages/_layout/index.tsx +43 -0
- package/client/pages/bug.tsx.old +60 -0
- package/client/pages/useHeader.tsx +50 -0
- package/client/services/captcha/index.ts +67 -0
- package/client/services/router/components/Link.tsx +46 -0
- package/client/services/router/components/Page.tsx +55 -0
- package/client/services/router/components/router.tsx +218 -0
- package/client/services/router/index.tsx +521 -0
- package/client/services/router/request/api.ts +267 -0
- package/client/services/router/request/history.ts +5 -0
- package/client/services/router/request/index.ts +53 -0
- package/client/services/router/request/multipart.ts +147 -0
- package/client/services/router/response/index.tsx +128 -0
- package/client/services/router/response/page.ts +86 -0
- package/client/services/socket/index.ts +147 -0
- package/client/utils/dom.ts +77 -0
- package/common/app/index.ts +9 -0
- package/common/data/chaines/index.ts +54 -0
- package/common/data/dates.ts +179 -0
- package/common/data/markdown.ts +73 -0
- package/common/data/rte/nodes.ts +83 -0
- package/common/data/stats.ts +90 -0
- package/common/errors/index.tsx +326 -0
- package/common/router/index.ts +213 -0
- package/common/router/layouts.ts +93 -0
- package/common/router/register.ts +55 -0
- package/common/router/request/api.ts +77 -0
- package/common/router/request/index.ts +35 -0
- package/common/router/response/index.ts +45 -0
- package/common/router/response/page.ts +128 -0
- package/common/utils/rte.ts +183 -0
- package/common/utils.ts +7 -0
- package/doc/TODO.md +71 -0
- package/doc/front/router.md +27 -0
- package/doc/workspace/workspace.png +0 -0
- package/doc/workspace/workspace2.png +0 -0
- package/doc/workspace/workspace_26.01.22.png +0 -0
- package/package.json +171 -0
- package/server/app/commands.ts +141 -0
- package/server/app/container/config.ts +203 -0
- package/server/app/container/console/index.ts +550 -0
- package/server/app/container/index.ts +137 -0
- package/server/app/index.ts +273 -0
- package/server/app/service/container.ts +88 -0
- package/server/app/service/index.ts +235 -0
- package/server/app.tsconfig.json +28 -0
- package/server/context.ts +4 -0
- package/server/index.ts +4 -0
- package/server/services/auth/index.ts +250 -0
- package/server/services/auth/old.ts +277 -0
- package/server/services/auth/router/index.ts +95 -0
- package/server/services/auth/router/request.ts +54 -0
- package/server/services/auth/router/service.json +6 -0
- package/server/services/auth/service.json +6 -0
- package/server/services/cache/commands.ts +41 -0
- package/server/services/cache/index.ts +297 -0
- package/server/services/cache/service.json +6 -0
- package/server/services/cron/CronTask.ts +86 -0
- package/server/services/cron/index.ts +112 -0
- package/server/services/cron/service.json +6 -0
- package/server/services/disks/driver.ts +103 -0
- package/server/services/disks/drivers/local/index.ts +188 -0
- package/server/services/disks/drivers/local/service.json +6 -0
- package/server/services/disks/drivers/s3/index.ts +301 -0
- package/server/services/disks/drivers/s3/service.json +6 -0
- package/server/services/disks/index.ts +90 -0
- package/server/services/disks/service.json +6 -0
- package/server/services/email/index.ts +188 -0
- package/server/services/email/utils.ts +53 -0
- package/server/services/fetch/index.ts +201 -0
- package/server/services/fetch/service.json +7 -0
- package/server/services/models.7z +0 -0
- package/server/services/prisma/Facet.ts +142 -0
- package/server/services/prisma/index.ts +201 -0
- package/server/services/prisma/service.json +6 -0
- package/server/services/router/http/index.ts +217 -0
- package/server/services/router/http/multipart.ts +102 -0
- package/server/services/router/http/session.ts.old +40 -0
- package/server/services/router/index.ts +801 -0
- package/server/services/router/request/api.ts +87 -0
- package/server/services/router/request/index.ts +184 -0
- package/server/services/router/request/service.ts +21 -0
- package/server/services/router/request/validation/zod.ts +180 -0
- package/server/services/router/response/index.ts +338 -0
- package/server/services/router/response/mask/Filter.ts +323 -0
- package/server/services/router/response/mask/index.ts +60 -0
- package/server/services/router/response/mask/selecteurs.ts +92 -0
- package/server/services/router/response/page/document.tsx +160 -0
- package/server/services/router/response/page/index.tsx +196 -0
- package/server/services/router/service.json +6 -0
- package/server/services/router/service.ts +36 -0
- package/server/services/schema/index.ts +44 -0
- package/server/services/schema/request.ts +49 -0
- package/server/services/schema/router/index.ts +28 -0
- package/server/services/schema/router/service.json +6 -0
- package/server/services/schema/service.json +6 -0
- package/server/services/security/encrypt/aes/index.ts +85 -0
- package/server/services/security/encrypt/aes/service.json +6 -0
- package/server/services/socket/index.ts +162 -0
- package/server/services/socket/scope.ts +226 -0
- package/server/services/socket/service.json +6 -0
- package/server/services_old/SocketClient.ts +92 -0
- package/server/services_old/Token.old.ts +97 -0
- package/server/utils/slug.ts +79 -0
- package/tsconfig.common.json +45 -0
- package/tsconfig.json +3 -0
- package/types/aliases.d.ts +54 -0
- package/types/global/modules.d.ts +49 -0
- package/types/global/utils.d.ts +103 -0
- package/types/icons.d.ts +1 -0
|
@@ -0,0 +1,211 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
);
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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)}';`;
|