5htp 0.0.6 → 0.0.8

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 (53) hide show
  1. package/package.json +4 -2
  2. package/readme.md +30 -0
  3. package/skeleton/.github/workflows/ci.yml +93 -0
  4. package/skeleton/.github/workflows/ecs-task.json +77 -0
  5. package/skeleton/Dockerfile +20 -0
  6. package/skeleton/docker-compose.yml +45 -0
  7. package/skeleton/identity.yaml +17 -0
  8. package/skeleton/package-lock.json +6139 -0
  9. package/skeleton/package.json +30 -0
  10. package/skeleton/src/client/assets/identity/logo.svg +64 -0
  11. package/skeleton/src/client/assets/identity/logoAndText.svg +105 -0
  12. package/skeleton/src/client/assets/illustration/launch.jpg +0 -0
  13. package/skeleton/src/client/assets/logos/google-play-store.svg +1 -0
  14. package/skeleton/src/client/assets/logos/googleauth.svg +9 -0
  15. package/skeleton/src/client/assets/patterns/interlaced.png +0 -0
  16. package/skeleton/src/client/assets/theme.less +278 -0
  17. package/skeleton/src/client/components/LoginModal.tsx +45 -0
  18. package/skeleton/src/client/pages/app/_layout/index.less +20 -0
  19. package/skeleton/src/client/pages/app/_layout/index.tsx +33 -0
  20. package/skeleton/src/client/pages/app/index.tsx +57 -0
  21. package/skeleton/src/client/pages/landing/_layout/index.less +145 -0
  22. package/skeleton/src/client/pages/landing/_layout/index.tsx +63 -0
  23. package/skeleton/src/client/pages/landing/index.tsx +73 -0
  24. package/skeleton/src/client/pages/preload.json +3 -0
  25. package/skeleton/src/client/tsconfig.json +32 -0
  26. package/skeleton/src/common/tsconfig.json +10 -0
  27. package/skeleton/src/server/config.ts +125 -0
  28. package/skeleton/src/server/index.ts +23 -0
  29. package/skeleton/src/server/routes/general.ts +66 -0
  30. package/skeleton/src/server/services/auth/index.ts +88 -0
  31. package/skeleton/src/server/tsconfig.json +34 -0
  32. package/src/{utils → app}/config.ts +20 -2
  33. package/src/app/index.ts +75 -0
  34. package/src/commands/build.ts +6 -1
  35. package/src/commands/deploy/web.ts +3 -3
  36. package/src/commands/dev.ts +11 -9
  37. package/src/commands/init.ts +85 -0
  38. package/src/compiler/client/identite.ts +7 -5
  39. package/src/compiler/client/index.ts +21 -18
  40. package/src/compiler/common/babel/index.ts +209 -201
  41. package/src/compiler/common/babel/plugins/injection-dependances/index.ts +2 -2
  42. package/src/compiler/common/babel/plugins/pages.ts +4 -2
  43. package/src/compiler/common/files/autres.ts +3 -1
  44. package/src/compiler/common/files/images.ts +2 -1
  45. package/src/compiler/common/files/style.ts +6 -4
  46. package/src/compiler/common/index.ts +13 -7
  47. package/src/compiler/common/plugins/indexage/icones-svg/index.ts +45 -37
  48. package/src/compiler/common/plugins/indexage/injection-dependances/index.ts +1 -1
  49. package/src/compiler/index.ts +24 -3
  50. package/src/compiler/server/index.ts +19 -19
  51. package/src/index.ts +4 -18
  52. package/src/paths.ts +12 -33
  53. package/tsconfig.json +1 -2
@@ -11,64 +11,72 @@ import defaultMetadataProvider from 'svgicons2svgfont/src/metadata';
11
11
  import Indexeur from '../indexeur';
12
12
  import cli from '@cli';
13
13
 
14
- // Configs
15
- const formats = ['woff2'];
16
- const dossierIcones = cli.paths.core.src + '/client/assets/icons/';
17
- const dossierSortie = cli.paths.app.bin + '/public/';
18
-
19
- const cacheTypes = cli.paths.core.src + '/types/icons.d.ts';
20
- const cacheIndex = dossierIcones + 'index.json';
21
-
22
14
  // Types
23
15
  import type { TIndexIcones } from '../../../babel/plugins/icones-svg';
16
+ import type App from '@cli/app';
24
17
 
25
18
  /*----------------------------------
26
19
  - UTILS
27
20
  ----------------------------------*/
28
- const refExistant = (dir: string): string[] => {
29
-
30
- let filelist: string[] = [];
31
-
32
- let files = fs.readdirSync(dossierIcones + dir);
33
- for (const file of files)
34
- if (fs.statSync(dossierIcones + dir + file).isDirectory())
35
- filelist = [
36
- ...filelist,
37
- ...refExistant(dir + file + '/')
38
- ];
39
- else if (file.endsWith('.svg'))
40
- filelist.push(dir + file.substring(0, file.length - 4));
41
-
42
- return filelist;
43
- };
44
21
 
45
22
  /*----------------------------------
46
23
  - PLUGIN
47
24
  ----------------------------------*/
48
- export default class SelecteursApi extends Indexeur {
25
+ export default class IconesSVG extends Indexeur {
49
26
 
50
27
  private icones: TIndexIcones = {};
51
28
  private iconesExistantes: string[] = [];
52
29
 
53
- public constructor() {
30
+ private formats = ['woff2'];
31
+ private dossierIcones: string;
32
+ private dossierSortie: string;
33
+
34
+ private cacheTypes: string;
35
+ private cacheIndex: string;
36
+
37
+ public constructor( app: App ) {
54
38
  super();
55
39
 
56
- if (fs.existsSync(cacheIndex)) {
40
+ this.formats = ['woff2'];
41
+ this.dossierIcones = cli.paths.core.src + '/client/assets/icons/';
42
+ this.dossierSortie = app.paths.bin + '/public/';
43
+
44
+ this.cacheTypes = cli.paths.core.src + '/types/icons.d.ts';
45
+ this.cacheIndex = this.dossierIcones + 'index.json';
46
+
47
+ if (fs.existsSync(this.cacheIndex)) {
57
48
 
58
49
  console.log('[icones] Getting icons list from cache ...');
59
- this.iconesExistantes = fs.readJSONSync(cacheIndex);
50
+ this.iconesExistantes = fs.readJSONSync(this.cacheIndex);
60
51
 
61
52
  } else {
62
53
 
63
54
  console.log('[icones] Référencement des icones existantes ...');
64
- this.iconesExistantes = refExistant('');
65
- fs.outputJSONSync(cacheIndex, this.iconesExistantes);
55
+ this.iconesExistantes = this.refExistant('');
56
+ fs.outputJSONSync(this.cacheIndex, this.iconesExistantes);
66
57
 
67
58
  }
68
59
 
69
60
  console.log('[icones] ' + this.iconesExistantes.length + ' icones référencées');
70
61
  }
71
62
 
63
+ private refExistant = (dir: string): string[] => {
64
+
65
+ let filelist: string[] = [];
66
+
67
+ let files = fs.readdirSync(this.dossierIcones + dir);
68
+ for (const file of files)
69
+ if (fs.statSync(this.dossierIcones + dir + file).isDirectory())
70
+ filelist = [
71
+ ...filelist,
72
+ ...this.refExistant(dir + file + '/')
73
+ ];
74
+ else if (file.endsWith('.svg'))
75
+ filelist.push(dir + file.substring(0, file.length - 4));
76
+
77
+ return filelist;
78
+ };
79
+
72
80
  /*----------------------------------
73
81
  - EVENTS
74
82
  ----------------------------------*/
@@ -109,7 +117,7 @@ export default class SelecteursApi extends Indexeur {
109
117
  let typeIcones: string[] = [];
110
118
  for (const id in this.icones) {
111
119
  const icone = this.icones[id]
112
- cheminIcones[ dossierIcones + icone.fichier ] = icone.id;
120
+ cheminIcones[ this.dossierIcones + icone.fichier ] = icone.id;
113
121
  typeIcones.push('"' + icone.nom + '"');
114
122
  }
115
123
 
@@ -128,9 +136,9 @@ export default class SelecteursApi extends Indexeur {
128
136
  const result = await webfont({
129
137
  files: Object.keys(cheminIcones),
130
138
  fontName: "icons",
131
- template: dossierIcones + 'template.css',
139
+ template: this.dossierIcones + 'template.css',
132
140
  // @ts-ignore
133
- formats,
141
+ formats: this.formats,
134
142
  templateClassName: 'svg',
135
143
  glyphTransformFn: (obj) => {
136
144
 
@@ -171,11 +179,11 @@ export default class SelecteursApi extends Indexeur {
171
179
  console.log('[icones] Enregistrement de la police avec ' + typeIcones.length +' icones ...');
172
180
 
173
181
  // Enregistrement fichiers
174
- for (const format of formats)
175
- fs.outputFileSync(dossierSortie + 'icons.' + format, result[ format ]);
176
- fs.outputFileSync(dossierSortie + 'icons.css', result.template);
182
+ for (const format of this.formats)
183
+ fs.outputFileSync(this.dossierSortie + 'icons.' + format, result[ format ]);
184
+ fs.outputFileSync(this.dossierSortie + 'icons.css', result.template);
177
185
 
178
- fs.outputFileSync(cacheTypes, 'export type TIcones = ' + typeIcones.join('|') );
186
+ fs.outputFileSync(this.cacheTypes, 'export type TIcones = ' + typeIcones.join('|') );
179
187
 
180
188
  console.log("[icones] Police enregistrée.");
181
189
 
@@ -10,7 +10,7 @@ import Indexeur from '../indexeur';
10
10
  import Stringify from '../_utils/Stringify';
11
11
  import cli from '@cli';
12
12
 
13
- const fichierSortie = cli.paths.app.cache + '/serveur/services.ts';
13
+ const fichierSortie = app.paths.cache + '/serveur/services.ts';
14
14
 
15
15
  /*----------------------------------
16
16
  - TYPES
@@ -3,6 +3,7 @@
3
3
  ----------------------------------*/
4
4
 
5
5
  // Npm
6
+ import path from 'path';
6
7
  import webpack from 'webpack';
7
8
  import fs from 'fs-extra';
8
9
 
@@ -15,6 +16,10 @@ import createClientConfig from './client';
15
16
  import { TCompileMode } from './common';
16
17
  import cli from '../';
17
18
 
19
+ // types
20
+
21
+ import type App from '../app';
22
+
18
23
  type TCompilerCallback = () => void
19
24
 
20
25
  /*----------------------------------
@@ -23,6 +28,7 @@ type TCompilerCallback = () => void
23
28
  export const compiling: { [compiler: string]: Promise<void> } = {};
24
29
 
25
30
  export default async function createCompilers(
31
+ app: App,
26
32
  mode: TCompileMode,
27
33
  { before, after }: {
28
34
  before?: TCompilerCallback,
@@ -31,12 +37,27 @@ export default async function createCompilers(
31
37
  ) {
32
38
 
33
39
  // Cleanup
34
- fs.emptyDirSync( cli.paths.app.bin );
40
+ fs.emptyDirSync( app.paths.bin );
41
+ fs.ensureDirSync( path.join(app.paths.bin, 'public') )
42
+ const publicFiles = fs.readdirSync(app.paths.public);
43
+ for (const publicFile of publicFiles)
44
+ fs.symlinkSync(
45
+ path.join(app.paths.public, publicFile),
46
+ path.join(app.paths.bin, 'public', publicFile)
47
+ );
48
+
49
+ // When the 5htp package is installed from npm link,
50
+ // Modules are installed locally and not glbally as with with the 5htp package from NPM.
51
+ // So we need to symbilnk the http-core node_modules in one of the parents of server.js.
52
+ fs.symlinkSync(
53
+ path.join(app.paths.root, '/node_modules/5htp-core/node_modules'),
54
+ path.join(app.paths.bin, '/node_modules')
55
+ );
35
56
 
36
57
  // Create compilers
37
58
  const multiCompiler = webpack([
38
- smp.wrap( createServerConfig(mode) ),
39
- smp.wrap( createClientConfig(mode) )
59
+ smp.wrap( createServerConfig(app, mode) ),
60
+ smp.wrap( createClientConfig(app, mode) )
40
61
  ]);
41
62
 
42
63
  for (const compiler of multiCompiler.compilers) {
@@ -4,11 +4,6 @@
4
4
 
5
5
  // Npm
6
6
  import webpack from 'webpack';
7
- import TsAlias from 'ts-alias';
8
- import path from 'path';
9
-
10
- // Plugins
11
- var nodeExternals = require('webpack-node-externals');
12
7
 
13
8
  // Minimizers
14
9
  const TerserPlugin = require("terser-webpack-plugin");
@@ -18,17 +13,22 @@ const TerserPlugin = require("terser-webpack-plugin");
18
13
  import cli from '@cli';
19
14
  import createCommonConfig, { TCompileMode, regex } from '../common';
20
15
 
16
+ // Type
17
+ import type App from '../../app';
18
+
21
19
  /*----------------------------------
22
20
  - CONFIG
23
21
  ----------------------------------*/
24
- export default function createCompiler( mode: TCompileMode ): webpack.Configuration {
22
+ export default function createCompiler( app: App, mode: TCompileMode ): webpack.Configuration {
25
23
 
26
24
  console.info(`Creating compiler for server (${mode}).`);
27
25
  const dev = mode === 'dev';
28
26
 
29
- const commonConfig = createCommonConfig('server', mode);
27
+ const commonConfig = createCommonConfig(app, 'server', mode);
28
+ const { aliases } = app.aliases.server.forWebpack(app.paths.root + '/node_modules');
30
29
 
31
- const { aliases } = cli.paths.aliases.server.forWebpack(cli.paths.app.root + '/node_modules');
30
+ console.log(`[${mode}] node_modules dirs:`, commonConfig.resolveLoader?.modules,
31
+ '\nModule aliases:', aliases);
32
32
 
33
33
  const config: webpack.Configuration = {
34
34
 
@@ -38,7 +38,7 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
38
38
  target: 'node',
39
39
  entry: {
40
40
  server: [
41
- cli.paths.app.root + '/src/server/index.ts',
41
+ app.paths.root + '/src/server/index.ts',
42
42
  ],
43
43
  },
44
44
 
@@ -48,7 +48,7 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
48
48
 
49
49
  libraryTarget: 'commonjs2',
50
50
 
51
- path: cli.paths.app.bin,
51
+ path: app.paths.bin,
52
52
  filename: '[name].js',
53
53
  publicPath: '/',
54
54
  assetModuleFilename: 'public/[hash][ext]',
@@ -74,7 +74,7 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
74
74
  ||
75
75
  request[0] === '/'
76
76
  ||
77
- cli.paths.aliases.server.containsAlias(request)
77
+ app.aliases.server.containsAlias(request)
78
78
  )
79
79
 
80
80
  //console.log('isNodeModule', request, isNodeModule);
@@ -96,7 +96,7 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
96
96
 
97
97
  alias: {
98
98
  ...aliases,
99
- "@root": cli.paths.app.root,
99
+ "@root": app.paths.root,
100
100
  },
101
101
 
102
102
  extensions: ['.ts', '.tsx', ".json", ".sql"],
@@ -111,17 +111,17 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
111
111
  test: regex.scripts,
112
112
  include: [
113
113
 
114
- cli.paths.app.root + '/src/client',
114
+ app.paths.root + '/src/client',
115
115
  cli.paths.core.root + '/src/client',
116
116
 
117
- cli.paths.app.root + '/src/common',
117
+ app.paths.root + '/src/common',
118
118
  cli.paths.core.root + '/src/common',
119
119
 
120
120
  // Dossiers server uniquement pour le bundle server
121
- cli.paths.app.root + '/src/server',
121
+ app.paths.root + '/src/server',
122
122
  cli.paths.core.root + '/src/server'
123
123
  ],
124
- rules: require('../common/babel')('server', dev)
124
+ rules: require('../common/babel')(app, 'server', dev)
125
125
  },
126
126
 
127
127
  // Les pages étan tà la fois compilées dans le bundle client et serveur
@@ -131,14 +131,14 @@ export default function createCompiler( mode: TCompileMode ): webpack.Configurat
131
131
  loader: 'null-loader'
132
132
  },
133
133
 
134
- ...require('../common/files/images')(dev, false),
134
+ ...require('../common/files/images')(app, dev, false),
135
135
 
136
- ...require('../common/files/autres')(dev, false),
136
+ ...require('../common/files/autres')(app, dev, false),
137
137
 
138
138
  // Exclude dev modules from production build
139
139
  /*...(dev ? [] : [
140
140
  {
141
- test: cli.paths.app.root + '/node_modules/react-deep-force-update/lib/index.js'),
141
+ test: app.paths.root + '/node_modules/react-deep-force-update/lib/index.js'),
142
142
  loader: 'null-loader',
143
143
  },
144
144
  ]),*/
package/src/index.ts CHANGED
@@ -10,7 +10,6 @@ import cp from 'child_process';
10
10
 
11
11
  // Libs
12
12
  import Paths from './paths';
13
- import ConfigParser from './utils/config';
14
13
 
15
14
  /*----------------------------------
16
15
  - TYPES
@@ -20,8 +19,6 @@ type TCliCommand = () => Promise<{
20
19
  run: () => Promise<void>
21
20
  }>
22
21
 
23
- export type TAppSide = 'server' | 'client'
24
-
25
22
  /*----------------------------------
26
23
  - CLASSE
27
24
  ----------------------------------*/
@@ -32,28 +29,15 @@ export class CLI {
32
29
 
33
30
  // Context
34
31
  public args: TObjetDonnees = {};
35
- public pkg = {
36
- app: require(this.paths.app.root + '/package.json'),
37
- core: require(this.paths.core.root + '/package.json'),
38
- }
39
-
40
- // config
41
- // WARNING: High level config files (env and services) shouldn't be loaded from the CLI
42
- // The CLI will be run on CircleCI, and no env file should be sent to this service
43
- public identity!: Core.Config.Identity;
44
32
 
45
33
  public constructor(
46
34
  public paths = new Paths( process.cwd() )
47
35
  ) {
48
36
  console.log(`[cli] Start debugger ...`);
49
37
  new Logger({ name: "cli", overwriteConsole: true });
50
-
38
+
51
39
  console.log(`[cli] Apply aliases ...`);
52
40
  this.paths.applyAliases();
53
-
54
- console.log(`[cli] Loading app config ...`);
55
- const configParser = new ConfigParser( paths.appRoot );
56
- this.identity = configParser.identity();
57
41
 
58
42
  this.start();
59
43
  }
@@ -64,6 +48,7 @@ export class CLI {
64
48
  // Les importations asynchrones permettent d'accéder à l'instance de cli via un import
65
49
  // WARN: We load commands asynchonously, so the aliases are applied before the file is imported
66
50
  public commands: { [name: string]: TCliCommand } = {
51
+ "init": () => import('./commands/init'),
67
52
  "dev": () => import('./commands/dev'),
68
53
  "build": () => import('./commands/build'),
69
54
  }
@@ -162,7 +147,7 @@ export class CLI {
162
147
  /*const tempFile = this.paths.app.root + '/.exec.sh';
163
148
  fs.outputFileSync(tempFile, '#! /bin/bash\n' + fullCommand);
164
149
  const wrappedCommand = `tilix --new-process -e bash -c 'chmod +x "${tempFile}"; "${tempFile}"; echo "Entrée pour continuer"; read a;'`;*/
165
- const wrappedCommand = `bash -c '${fullCommand}; echo "Entrée pour continuer"; read a;'`;
150
+ const wrappedCommand = `bash -c '${fullCommand}'`;
166
151
  console.log("Running command: " + wrappedCommand)
167
152
  //await this.waitForInput('enter');
168
153
 
@@ -180,6 +165,7 @@ export class CLI {
180
165
 
181
166
  //fs.removeSync(tempFile);
182
167
 
168
+ console.log("Command finished.");
183
169
  resolve();
184
170
  })
185
171
 
package/src/paths.ts CHANGED
@@ -4,23 +4,24 @@
4
4
 
5
5
  // Npm
6
6
  import path from 'path';
7
+ import TsAlias from 'ts-alias';
7
8
  import moduleAlias from 'module-alias';
8
9
 
9
10
  // Core
10
- import TsAlias from 'ts-alias';
11
11
 
12
12
  /*----------------------------------
13
13
  - TYPES
14
14
  ----------------------------------*/
15
15
 
16
- import type { TAppSide } from '.';
16
+ import type App from './app';
17
+ import type { TAppSide } from './app';
17
18
 
18
19
  export type TPathInfos = {
19
20
 
20
21
  original: string,
21
22
  absolute: string,
22
23
  relative: string,
23
- forImport: string,
24
+ //forImport: string,
24
25
 
25
26
  name: string,
26
27
  extension: string,
@@ -52,16 +53,6 @@ export default class Paths {
52
53
  pages: this.coreRoot + '/src/client/pages',
53
54
  }
54
55
 
55
- public app = {
56
- root: this.appRoot,
57
- src: this.appRoot + '/src',
58
- bin: this.appRoot + '/bin',
59
- data: this.appRoot + '/var/data',
60
- public: this.appRoot + '/bin/public',
61
- pages: this.appRoot + '/src/client/pages',
62
- cache: this.appRoot + '/src/.cache'
63
- }
64
-
65
56
  /*----------------------------------
66
57
  - EXTRACTION
67
58
  ----------------------------------*/
@@ -100,7 +91,8 @@ export default class Paths {
100
91
  absolute: cheminAbsolu,
101
92
  relative,
102
93
 
103
- forImport: this.withAlias(cheminAbsolu, side),
94
+ // Not used anymore, but can be useful in the future
95
+ //forImport: this.withAlias(cheminAbsolu, side),
104
96
 
105
97
  name: nomReel,
106
98
  extension,
@@ -110,10 +102,10 @@ export default class Paths {
110
102
  return retour;
111
103
  }
112
104
 
113
- public getPageChunk( file: string ) {
105
+ public getPageChunk( app: App, file: string ) {
114
106
 
115
- const infos = this.infos( file, file.startsWith( this.app.pages )
116
- ? this.app.pages
107
+ const infos = this.infos( file, file.startsWith( app.paths.pages )
108
+ ? app.paths.pages
117
109
  : this.core.pages,
118
110
  );
119
111
 
@@ -131,24 +123,11 @@ export default class Paths {
131
123
 
132
124
  }
133
125
 
134
- /*----------------------------------
135
- - ALIAS
136
- ----------------------------------*/
137
-
138
- public aliases = {
139
- client: new TsAlias(this.app.root + '/src/client'),
140
- server: new TsAlias(this.app.root + '/src/server'),
141
- }
142
-
143
- public withAlias = (filename: string, side: TAppSide) =>
144
- this.aliases[side].apply(filename);
145
-
146
- public withoutAlias = (filename: string, side: TAppSide) =>
147
- this.aliases[side].realpath(filename);
148
-
149
126
  public applyAliases() {
150
127
 
151
- const aliases = new TsAlias( this.core.cli );
128
+ const aliases = new TsAlias({
129
+ rootDir: this.core.cli
130
+ });
152
131
 
153
132
  console.log('Applying Aliases ...', aliases);
154
133
 
package/tsconfig.json CHANGED
@@ -25,8 +25,7 @@
25
25
 
26
26
  "paths": {
27
27
  "@cli/*": [ "./*" ],
28
- "@cli": [ "./" ],
29
- "@server_old/*": [ "../src/server/*" ]
28
+ "@cli": [ "./" ]
30
29
  },
31
30
  },
32
31