5htp 0.3.2-1 → 0.3.3-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/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.2-1",
4
+ "version": "0.3.3-1",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp.git",
7
7
  "license": "MIT",
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
 
@@ -18,12 +18,6 @@ import type { TAppSide, App } from '@cli/app';
18
18
  - REGLES
19
19
  ----------------------------------*/
20
20
  module.exports = (app: App, side: TAppSide, dev: boolean): webpack.RuleSetRule[] => {
21
-
22
- const pkg = {
23
- app: require(app.paths.root + '/package.json'),
24
- core: require(cli.paths.core.root + '/package.json'),
25
- }
26
-
27
21
  return [{
28
22
  loader: 'babel-loader',
29
23
  options: {
@@ -54,7 +48,7 @@ module.exports = (app: App, side: TAppSide, dev: boolean): webpack.RuleSetRule[]
54
48
  "corejs": 3, // default would be 2
55
49
 
56
50
  targets: {
57
- browsers: pkg.app.browserslist,
51
+ browsers: app.packageJson.browserslist,
58
52
  },
59
53
  forceAllTransforms: !dev, // for UglifyJS
60
54
  modules: false,
@@ -33,6 +33,8 @@ function Plugin (babel) {
33
33
 
34
34
  const plugin: PluginObj<{
35
35
  referencerIcone: (nomBrut: string) => string | null,
36
+ setNodeAsProcessed: (node: types.Node) => types.Node;
37
+ hasBeenProcessed: (node: types.Node) => boolean | undefined,
36
38
  fichier: string,
37
39
  traiter: boolean,
38
40
  iconeTrouvee: boolean,
@@ -85,6 +87,14 @@ function Plugin (babel) {
85
87
  return this.icones[ cheminIconeBrut ].id;
86
88
  }
87
89
 
90
+ this.setNodeAsProcessed = (node: types.Node) => {
91
+ node.innerComments = [{ type: 'CommentBlock', 'value': '@iconId' }]
92
+ return node;
93
+ }
94
+
95
+ this.hasBeenProcessed = (node: types.Node) =>
96
+ node.innerComments?.some( c => c.value === '@iconId' )
97
+
88
98
  },
89
99
  visitor: {
90
100
  Program: {
@@ -106,6 +116,8 @@ function Plugin (babel) {
106
116
  path.node.leadingComments.length !== 0
107
117
  &&
108
118
  path.node.leadingComments[0].value === ' @icon '
119
+ &&
120
+ !this.hasBeenProcessed( path.node )
109
121
  ) {
110
122
 
111
123
  // Remplacement par id
@@ -114,7 +126,9 @@ function Plugin (babel) {
114
126
  return;
115
127
 
116
128
  path.replaceWith(
117
- t.stringLiteral(idIcone)
129
+ this.setNodeAsProcessed(
130
+ t.stringLiteral(idIcone)
131
+ )
118
132
  );
119
133
 
120
134
  path.skip();
@@ -130,17 +144,24 @@ function Plugin (babel) {
130
144
  path.node.key.name === 'icon'
131
145
  &&
132
146
  path.node.value?.type === 'StringLiteral'
147
+ &&
148
+ !this.hasBeenProcessed( path.node )
133
149
  ) {
134
150
 
151
+ if (this.fichier.includes("award"))
152
+ console.log( path.node.value.value, path.node.innerComments,path.node.leadingComments, path.node.trailingComments );
153
+
135
154
  // Remplacement par id
136
155
  const idIcone = this.referencerIcone(path.node.value.value);
137
156
  if (idIcone === null)
138
157
  return;
139
158
 
140
159
  path.replaceWith(
141
- t.objectProperty(
142
- t.identifier('icon'),
143
- t.stringLiteral( idIcone )
160
+ this.setNodeAsProcessed(
161
+ t.objectProperty(
162
+ t.identifier('icon'),
163
+ t.stringLiteral( idIcone ),
164
+ )
144
165
  )
145
166
  );
146
167
 
@@ -158,6 +179,8 @@ function Plugin (babel) {
158
179
  path.node.name.name.startsWith("icon")
159
180
  &&
160
181
  path.node.value
182
+ &&
183
+ !this.hasBeenProcessed( path.node )
161
184
  ) {
162
185
 
163
186
  const nomAttr = path.node.name.name;
@@ -199,10 +222,12 @@ function Plugin (babel) {
199
222
  } else
200
223
  return;
201
224
 
202
- path.replaceWith(
203
- t.jsxAttribute(
204
- t.jsxIdentifier( nomAttr ),
205
- remplacement
225
+ path.replaceWith(
226
+ this.setNodeAsProcessed(
227
+ t.jsxAttribute(
228
+ t.jsxIdentifier( nomAttr ),
229
+ remplacement
230
+ )
206
231
  )
207
232
  );
208
233
 
@@ -224,6 +249,8 @@ function Plugin (babel) {
224
249
  path.node.openingElement.name.type === 'JSXIdentifier'
225
250
  &&
226
251
  path.node.openingElement.name.name === 'i'
252
+ &&
253
+ !this.hasBeenProcessed( path.node )
227
254
  ) {
228
255
 
229
256
  // Extraction des attributs src et class
@@ -291,7 +318,7 @@ function Plugin (babel) {
291
318
  ? attrs.class.expression
292
319
  : null
293
320
 
294
- path.replaceWith(
321
+ path.replaceWith( this.setNodeAsProcessed(
295
322
 
296
323
  // Balise <i>
297
324
  t.jsxElement(
@@ -330,7 +357,7 @@ function Plugin (babel) {
330
357
  path.node.children,
331
358
  path.node.selfClosing
332
359
  )
333
- );
360
+ ));
334
361
  }
335
362
  }
336
363
  },
@@ -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
 
@@ -90,12 +90,14 @@ export default class IconesSVG extends Indexeur {
90
90
 
91
91
  let maj = false;
92
92
 
93
+ //console.log('======maj', Object.keys( donneesMeta ));
94
+
93
95
  // Pour chacune d'entre elles
94
96
  for (const cheminIcone in donneesMeta) {
95
97
 
96
98
  // Verif si existante
97
99
  if (!this.iconesExistantes.includes( cheminIcone ))
98
- console.error(`L'icone ${donneesMeta[cheminIcone].nom} (${cheminIcone}) utilisée dans le fichier ${fichier} n'existe pas.`);
100
+ console.error(`The icon you made reference to "${donneesMeta[cheminIcone].nom}" (${cheminIcone}) in the file ${fichier} doesn't exists.`);
99
101
  // Verif si déjà référencée
100
102
  else if (this.icones[ cheminIcone ] === undefined) {
101
103
  // Sinon, référencement
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