5htp 0.3.3 → 0.3.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.3.3",
4
+ "version": "0.3.6",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp.git",
7
7
  "license": "MIT",
@@ -73,7 +73,6 @@
73
73
  "ts-alias": "^0.0.7",
74
74
  "ts-node": "^10.9.1",
75
75
  "webfont": "^11.2.26",
76
- "webpack": "^5.56.0",
77
76
  "webpack-assets-manifest": "^5.0.6",
78
77
  "webpack-bundle-analyzer": "^4.4.2",
79
78
  "webpack-dev-middleware": "^5.1.0",
@@ -82,11 +81,13 @@
82
81
  "webpack-virtual-modules": "^0.4.3"
83
82
  },
84
83
  "devDependencies": {
84
+ "@types/babel__preset-env": "^7.9.6",
85
85
  "@types/favicons": "^6.2.2",
86
86
  "@types/fs-extra": "^9.0.12",
87
87
  "@types/node": "^16.9.1",
88
88
  "@types/nodemailer": "^6.4.4",
89
89
  "@types/prompts": "^2.0.14",
90
- "@types/webpack-env": "^1.16.2"
90
+ "@types/webpack-env": "^1.16.2",
91
+ "webpack": "^5.89.0"
91
92
  }
92
93
  }
package/src/app/index.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  // npm
6
6
  import path from 'path';
7
7
  import TsAlias from 'ts-alias';
8
+ import fs from 'fs-extra';
8
9
 
9
10
  // Cre
10
11
  import cli from '..';
@@ -31,6 +32,8 @@ export class App {
31
32
 
32
33
  public env: TEnvConfig;
33
34
 
35
+ public packageJson: {[key: string]: any};
36
+
34
37
  public paths = {
35
38
 
36
39
  root: cli.paths.appRoot,
@@ -71,6 +74,8 @@ export class App {
71
74
  const configParser = new ConfigParser( cli.paths.appRoot );
72
75
  this.identity = configParser.identity();
73
76
  this.env = configParser.env();
77
+ this.packageJson = this.loadPkg();
78
+
74
79
  }
75
80
 
76
81
  /*----------------------------------
@@ -95,6 +100,10 @@ export class App {
95
100
  debug: false
96
101
  }),
97
102
  }
103
+
104
+ private loadPkg() {
105
+ return fs.readJSONSync(this.paths.root + '/package.json');
106
+ }
98
107
  }
99
108
 
100
109
  export const app = new App
@@ -42,11 +42,9 @@ export async function run() {
42
42
  fs.emptyDirSync(temp);
43
43
 
44
44
  // Merge package.json: framework + app
45
- const appPkg = fs.readJSONSync(app.paths.root + '/package.json');
46
- const corePkg = fs.readJSONSync(cli.paths.core.root + '/package.json');
47
45
  fs.outputJSONSync(temp + '/package.json', {
48
46
  ...appPkg,
49
- dependencies: mergeDeps(corePkg, appPkg),
47
+ dependencies: mergeDeps(cli.packageJson, appPkg),
50
48
  devDependencies: {}
51
49
  }, { spaces: 4 });
52
50
 
@@ -3,11 +3,8 @@
3
3
  ----------------------------------*/
4
4
 
5
5
  // Npm
6
- import path from 'path';
7
6
  import type webpack from 'webpack';
8
- import * as types from '@babel/types'
9
- import PresetReact from '@babel/preset-react';
10
-
7
+ import PresetBabel, { Options } from '@babel/preset-env';
11
8
  // Core
12
9
  import PluginIndexage from '../plugins/indexage';
13
10
 
@@ -19,11 +16,31 @@ import type { TAppSide, App } from '@cli/app';
19
16
  ----------------------------------*/
20
17
  module.exports = (app: App, side: TAppSide, dev: boolean): webpack.RuleSetRule[] => {
21
18
 
22
- const pkg = {
23
- app: require(app.paths.root + '/package.json'),
24
- core: require(cli.paths.core.root + '/package.json'),
19
+ const babelPresetEnvConfig: Options = side === 'client' ? {
20
+
21
+ // Ajoute automatiquement les polyfills babel
22
+ // https://stackoverflow.com/a/61517521/12199605
23
+ "useBuiltIns": "usage", // alternative mode: "entry"
24
+ "corejs": 3, // default would be 2
25
+
26
+ targets: {
27
+ browsers: dev
28
+ ? 'last 2 versions'
29
+ : app.packageJson.browserslist,
30
+ },
31
+ forceAllTransforms: !dev, // for UglifyJS
32
+ modules: false,
33
+ debug: false,
34
+ bugfixes: !dev
35
+ } : {
36
+ targets: {
37
+ node: true,//pkg.engines.node.match(/(\d+\.?)+/)[0],
38
+ },
39
+ modules: false,
40
+ useBuiltIns: false,
41
+ debug: false,
25
42
  }
26
-
43
+
27
44
  return [{
28
45
  loader: 'babel-loader',
29
46
  options: {
@@ -46,27 +63,7 @@ module.exports = (app: App, side: TAppSide, dev: boolean): webpack.RuleSetRule[]
46
63
  presets: [
47
64
 
48
65
  // https://github.com/babel/babel-preset-env
49
- [require('@babel/preset-env'), side === 'client' ? {
50
-
51
- // Ajoute automatiquement les polyfills babel
52
- // https://stackoverflow.com/a/61517521/12199605
53
- "useBuiltIns": "usage", // alternative mode: "entry"
54
- "corejs": 3, // default would be 2
55
-
56
- targets: {
57
- browsers: pkg.app.browserslist,
58
- },
59
- forceAllTransforms: !dev, // for UglifyJS
60
- modules: false,
61
- debug: false,
62
- } : {
63
- targets: {
64
- node: true,//pkg.engines.node.match(/(\d+\.?)+/)[0],
65
- },
66
- modules: false,
67
- useBuiltIns: false,
68
- debug: false,
69
- }],
66
+ [PresetBabel, babelPresetEnvConfig],
70
67
 
71
68
  [require("@babel/preset-typescript"), {
72
69
  useDefineForClassFields: true,
@@ -9,11 +9,6 @@ import type App from '../../../app';
9
9
 
10
10
  module.exports = (app: App, dev: Boolean, client: boolean) => {
11
11
 
12
- // OBSOLETE: A projet can have multiple themes,
13
- // And the user have to choose in which score he wants to use a theme (by importing it)
14
- const paletteLess = fs.readFileSync( app.paths.src + '/client/assets/themes/main.less', 'utf8');
15
- const themeVars = lessToJs(paletteLess, { resolveVariables: true, stripPrefix: true });
16
-
17
12
  return [
18
13
 
19
14
  // Apply PostCSS plugins including autoprefixer
@@ -53,8 +48,6 @@ module.exports = (app: App, dev: Boolean, client: boolean) => {
53
48
  // Défault = parens-division depuis 4.0.0
54
49
  // https://lesscss.org/usage/#less-options-math
55
50
  math: 'always',
56
-
57
- globalVars: themeVars
58
51
  },
59
52
  }
60
53
  },
@@ -16,7 +16,7 @@ import InjectDeps from './plugins/indexage/injection-dependances';
16
16
  import cli from '../..';
17
17
 
18
18
  // Type
19
- import type App from '../../app';
19
+ import type { App } from '../../app';
20
20
  import type { TAppSide } from '../../app';
21
21
 
22
22
  /*----------------------------------
@@ -68,11 +68,16 @@ export default function createCommonConfig( app: App, side: TAppSide, mode: TCom
68
68
  // https://webpack.js.org/plugins/define-plugin/
69
69
  new webpack.DefinePlugin({
70
70
 
71
+ // Flags
71
72
  __DEV__: dev,
72
73
  SERVER: side === 'server',
73
- BUILD_DATE: JSON.stringify(dayjs().format('YY.MM.DD-HH.mm')),
74
74
 
75
+ // Core
76
+ CORE_VERSION: JSON.stringify( cli.packageJson.version ),
75
77
  CORE_PATH: JSON.stringify(cli.paths.core.root),
78
+
79
+ // Application
80
+ BUILD_DATE: JSON.stringify(dayjs().format('YY.MM.DD-HH.mm')),
76
81
  APP_PATH: JSON.stringify(app.paths.root),
77
82
  APP_NAME: JSON.stringify(app.identity.web.title),
78
83
 
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ process.traceDeprecation = true;
7
7
  ----------------------------------*/
8
8
 
9
9
  // Npm
10
+ import fs from 'fs-extra';
10
11
  import cp from 'child_process';
11
12
 
12
13
  // Libs
@@ -37,6 +38,8 @@ export class CLI {
37
38
 
38
39
  public debug: boolean = false;
39
40
 
41
+ public packageJson: {[key: string]: any};
42
+
40
43
  public constructor(
41
44
  public paths = new Paths( process.cwd() )
42
45
  ) {
@@ -45,6 +48,8 @@ export class CLI {
45
48
  this.debug && console.log(`[cli] Apply aliases ...`);
46
49
  this.paths.applyAliases();
47
50
 
51
+ this.packageJson = this.loadPkg();
52
+
48
53
  this.start();
49
54
  }
50
55
 
@@ -59,6 +64,10 @@ export class CLI {
59
64
  "build": () => import('./commands/build'),
60
65
  }
61
66
 
67
+ private loadPkg() {
68
+ return fs.readJSONSync(this.paths.core.root + '/package.json');
69
+ }
70
+
62
71
  public start() {
63
72
 
64
73
  const [, , commandName, ...argv] = process.argv;
@@ -90,7 +99,7 @@ export class CLI {
90
99
  if (Array.isArray( curVal ))
91
100
  curVal.push(a);
92
101
  else
93
- options[opt] = a;
102
+ options[opt] = a;
94
103
 
95
104
  opt = null;
96
105