leanweb 1.3.6 → 2.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.
package/README.md CHANGED
@@ -56,7 +56,6 @@ looks like:
56
56
  "name": "demo",
57
57
  "version": "0.4.5",
58
58
  "components": ["root"],
59
- "imports": [],
60
59
  "resources": ["resources/"]
61
60
  }
62
61
  ```
@@ -106,13 +105,6 @@ changes in the code, and save, the browser should refresh automatically to
106
105
  reflect your changes.
107
106
  <img src='https://leanweb.app/images/leanweb-serve.png' alt='lw serve' width='640'/>
108
107
 
109
- ### `leanweb electron` or `lw electron`
110
-
111
- Run `lw electron` or even `lw elec` and you should see an electron app window
112
- open as follows:
113
-
114
- <img src='https://leanweb.app/images/leanweb-electron.png' alt='lw electron' width='640'/>
115
-
116
108
  ### `leanweb generate` or `lw generate`
117
109
 
118
110
  Let's create a `login` web component with `lw generate` or `lw g`.
@@ -129,7 +121,6 @@ Now the `leanweb.json` has one more entry in the component list:
129
121
  "name": "demo",
130
122
  "version": "0.4.5",
131
123
  "components": ["root", "login"],
132
- "imports": [],
133
124
  "resources": ["resources/"]
134
125
  }
135
126
  ```
@@ -164,11 +155,6 @@ the `login` component does not affect other components.
164
155
 
165
156
  <img src='https://leanweb.app/images/leanweb-serve-1.png' alt='lw serve' width='640'/>
166
157
 
167
- Run `lw electron` again, and you will see the same changes reflected in
168
- the electron app.
169
-
170
- <img src='https://leanweb.app/images/leanweb-electron-1.png' alt='lw electron' width='640'/>
171
-
172
158
  ### `leanweb dist` or `lw dist`
173
159
 
174
160
  Run `lw dist`, and a `dist` directory will be created with minified files
@@ -496,21 +482,6 @@ selectedRange = 10;
496
482
 
497
483
  <img src='https://leanweb.app/images/leanweb-form-binding-range.gif' alt='Leanweb Form Binding Range' />
498
484
 
499
- ## Import libraries from `node_modules`
500
-
501
- Assuming npm module `lodash-es` is installed, you could use any of the
502
- following `import` statements for your web component class:
503
-
504
- ```javascript
505
- import get from "/node_modules/lodash-es/get.js"; // find from node_modules
506
- ```
507
-
508
- Importing a JSON file:
509
-
510
- ```javascript
511
- import someJSON from "./some.json";
512
- ```
513
-
514
485
  ## Component Communication
515
486
 
516
487
  The following project demonstrates how Leanweb helps web components to talk to
package/commands/build.js CHANGED
@@ -1,132 +1,103 @@
1
- import fs from 'fs';
2
- import fse from 'fs-extra';
3
- import { minify } from 'html-minifier';
4
- import * as utils from './utils.js';
5
- import * as parser from '../lib/lw-html-parser.js';
6
-
7
1
  import path from 'path';
8
2
  import { fileURLToPath } from 'url';
9
3
  const __filename = fileURLToPath(import.meta.url);
10
4
  const __dirname = path.dirname(__filename);
11
-
12
5
  import { createRequire } from "module";
13
6
  const require = createRequire(import.meta.url);
14
7
 
15
- (async () => {
16
- let env;
17
- const args = process.argv;
18
- if (args.length >= 3) {
19
- env = args[2];
20
- }
21
-
22
- const leanwebPackageJSON = require(`${__dirname}/../package.json`);
23
-
24
- const buildModule = (projectPath) => {
25
-
26
- const project = require(`${projectPath}/${utils.dirs.src}/leanweb.json`);
27
- const isMain = process.cwd() === projectPath;
28
-
29
- const buildDir = isMain ? utils.dirs.build : `${utils.dirs.build}/_dependencies/${project.name}`;
30
- fs.mkdirSync(buildDir, { recursive: true });
31
-
32
- let depImports = '';
33
- project.imports?.forEach(im => {
34
- let depPath;
35
- if (im.indexOf('/') < 0) {
36
- depPath = `${process.cwd()}/node_modules/${im}`;
37
- } else {
38
- if (im.startsWith('./')) {
39
- depPath = `${process.cwd()}/${im}`;
40
- } else if (im.startsWith('/')) {
41
- depPath = im;
42
- } else {
43
- depPath = `${process.cwd()}/node_modules/${im}`;
44
- }
45
- }
46
- const depName = buildModule(depPath);
47
- if (isMain) {
48
- depImports += `import './_dependencies/${depName}/${depName}.js';\n`;
49
- } else {
50
- depImports += `import '../${depName}/${depName}.js';\n`;
51
- }
8
+ import fs from 'fs';
9
+ import fse from 'fs-extra';
10
+ import { minify } from 'html-minifier';
11
+ import * as utils from './utils.js';
12
+ import * as parser from '../lib/lw-html-parser.js';
52
13
 
14
+ (async () => {
15
+ let env;
16
+ const args = process.argv;
17
+ if (args.length >= 3) {
18
+ env = args[2];
19
+ }
20
+
21
+ const leanwebPackageJSON = require(`${__dirname}/../package.json`);
22
+
23
+ const buildModule = (projectPath) => {
24
+
25
+ const project = require(`${projectPath}/${utils.dirs.src}/leanweb.json`);
26
+
27
+ fs.mkdirSync(utils.dirs.build, { recursive: true });
28
+
29
+ const copySrc = () => {
30
+ fse.copySync(`${projectPath}/${utils.dirs.src}/`, utils.dirs.build, { filter: utils.copySymbolLinkFilter });
31
+ };
32
+
33
+ const copyEnv = () => {
34
+ if (env) {
35
+ fse.copySync(`${utils.dirs.build}/env/${env}.js`, `${utils.dirs.build}/env.js`);
36
+ }
37
+ };
38
+
39
+ const buildJS = () => {
40
+ const jsString = project.components.reduce((acc, cur) => {
41
+ const cmpName = utils.getComponentName(cur);
42
+ let importString = `import './components/${cur}/${cmpName}.js';`;
43
+ return acc + importString + '\n';
44
+ }, '');
45
+ fs.writeFileSync(`${utils.dirs.build}/${project.name}.js`, jsString);
46
+ };
47
+
48
+ const buildHTML = () => {
49
+ project.components.forEach(cmp => {
50
+ const cmpName = utils.getComponentName(cmp);
51
+ const htmlFilename = `${utils.dirs.build}/components/${cmp}/${cmpName}.html`;
52
+ const htmlFileExists = fs.existsSync(htmlFilename);
53
+ if (htmlFileExists) {
54
+ const scssFilename = `${utils.dirs.build}/components/${cmp}/${cmpName}.scss`;
55
+ const scssFileExists = fs.existsSync(scssFilename);
56
+ let cssString = '';
57
+ if (scssFileExists) {
58
+ let scssString = `@use "global-styles.scss";\n`;
59
+ scssString += fs.readFileSync(scssFilename, 'utf8');
60
+ scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
61
+ cssString = utils.buildCSS(scssString, utils.dirs.build, `${utils.dirs.build}/components/${cmp}`);
62
+ }
63
+ const styleString = cssString || '';
64
+ const htmlString = fs.readFileSync(htmlFilename, 'utf8');
65
+ const minifiedHtml = minify(htmlString, {
66
+ caseSensitive: true,
67
+ collapseWhitespace: true,
68
+ minifyCSS: true,
69
+ minifyJS: true,
70
+ removeComments: true,
71
+ });
72
+ const ast = parser.parse(minifiedHtml);
73
+ ast.css = styleString;
74
+ ast.componentFullName = project.name + '-' + cmp.replace(/\//g, '-');
75
+ ast.runtimeVersion = project.version;
76
+ ast.builderVersion = leanwebPackageJSON.version;
77
+ fs.writeFileSync(`${utils.dirs.build}/components/${cmp}/ast.js`, `export default ${JSON.stringify(ast, null, 0)};`);
78
+ }
53
79
  });
54
-
55
- const copySrc = () => {
56
- fse.copySync(`${projectPath}/${utils.dirs.src}/`, buildDir, { filter: utils.copySymbolLinkFilter });
57
- };
58
-
59
- const copyEnv = () => {
60
- if (env) {
61
- fse.copySync(`${buildDir}/env/${env}.js`, `${buildDir}/env.js`);
62
- }
63
- };
64
-
65
- const buildJS = () => {
66
- const jsString = project.components.reduce((acc, cur) => {
67
- const cmpName = utils.getComponentName(cur);
68
- let importString = `import './components/${cur}/${cmpName}.js';`;
69
- return acc + importString + '\n';
70
- }, depImports + '\n');
71
- fs.writeFileSync(`${buildDir}/${project.name}.js`, jsString);
72
- };
73
-
74
- const buildHTML = () => {
75
- project.components.forEach(cmp => {
76
- const cmpName = utils.getComponentName(cmp);
77
- const htmlFilename = `${buildDir}/components/${cmp}/${cmpName}.html`;
78
- const htmlFileExists = fs.existsSync(htmlFilename);
79
- if (htmlFileExists) {
80
-
81
- const scssFilename = `${buildDir}/components/${cmp}/${cmpName}.scss`;
82
- const scssFileExists = fs.existsSync(scssFilename);
83
- let cssString = '';
84
- if (scssFileExists) {
85
- let scssString = `@use "global-styles.scss";\n`;
86
- scssString += fs.readFileSync(scssFilename, 'utf8');
87
- scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
88
- cssString = utils.buildCSS(scssString, buildDir, `${buildDir}/components/${cmp}`);
89
- }
90
- const styleString = cssString || '';
91
- const htmlString = fs.readFileSync(htmlFilename, 'utf8');
92
- const minifiedHtml = minify(htmlString, {
93
- caseSensitive: true,
94
- collapseWhitespace: true,
95
- minifyCSS: true,
96
- minifyJS: true,
97
- removeComments: true,
98
- });
99
- const ast = parser.parse(minifiedHtml);
100
- ast.css = styleString;
101
- ast.componentFullName = project.name + '-' + cmp.replace(/\//g, '-');
102
- ast.runtimeVersion = project.version;
103
- ast.builderVersion = leanwebPackageJSON.version;
104
- fs.writeFileSync(`${buildDir}/components/${cmp}/ast.js`, `export default ${JSON.stringify(ast, null, 0)};`);
105
- }
106
- });
107
- const htmlString = fs.readFileSync(`${buildDir}/index.html`, 'utf8');
108
- fs.writeFileSync(`${buildDir}/index.html`, htmlString);
109
- };
110
-
111
- const buildSCSS = () => {
112
- const projectScssFilename = `${projectPath}/${utils.dirs.src}/${project.name}.scss`;
113
- let projectCssString = '';
114
- if (fs.existsSync(projectScssFilename)) {
115
- const projectScssString = fs.readFileSync(projectScssFilename, 'utf8');
116
- projectCssString += utils.buildCSS(projectScssString, buildDir);
117
- }
118
- fs.writeFileSync(`${buildDir}/${project.name}.css`, projectCssString);
119
- };
120
-
121
- copySrc();
122
- copyEnv();
123
- buildJS();
124
- buildSCSS();
125
- buildHTML();
126
-
127
- return project.name;
128
- };
129
-
130
- buildModule(process.cwd());
80
+ };
81
+
82
+ const buildSCSS = () => {
83
+ const projectScssFilename = `${projectPath}/${utils.dirs.src}/${project.name}.scss`;
84
+ let projectCssString = '';
85
+ if (fs.existsSync(projectScssFilename)) {
86
+ const projectScssString = fs.readFileSync(projectScssFilename, 'utf8');
87
+ projectCssString += utils.buildCSS(projectScssString, utils.dirs.build);
88
+ }
89
+ fs.writeFileSync(`${utils.dirs.build}/${project.name}.css`, projectCssString);
90
+ };
91
+
92
+ copySrc();
93
+ copyEnv();
94
+ buildJS();
95
+ buildSCSS();
96
+ buildHTML();
97
+
98
+ return project.name;
99
+ };
100
+
101
+ buildModule(process.cwd());
131
102
 
132
103
  })();
package/commands/clean.js CHANGED
@@ -2,7 +2,7 @@ import fs from 'fs';
2
2
  import * as utils from './utils.js';
3
3
 
4
4
  (async () => {
5
- fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
6
- fs.rmSync(utils.dirs.dist + '/', { recursive: true, force: true });
7
- fs.rmSync(utils.dirs.serve + '/', { recursive: true, force: true });
5
+ fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
6
+ fs.rmSync(utils.dirs.dist + '/', { recursive: true, force: true });
7
+ fs.rmSync(utils.dirs.serve + '/', { recursive: true, force: true });
8
8
  })();
@@ -1,29 +1,28 @@
1
- import fs from 'fs';
2
- import * as utils from './utils.js';
3
-
4
1
  import { createRequire } from "module";
5
2
  const require = createRequire(import.meta.url);
6
3
 
4
+ import fs from 'fs';
5
+ import * as utils from './utils.js';
6
+
7
7
  (async () => {
8
- const args = process.argv;
9
- if (args.length < 3) {
10
- console.log('Usage: lw destroy project-name');
11
- console.log(`This will delete ${utils.dirs.src}/ ${utils.dirs.build}/ ${utils.dirs.dist}/ ${utils.dirs.serve}/ and ${utils.dirs.electron}/`)
12
- return;
13
- }
8
+ const args = process.argv;
9
+ if (args.length < 3) {
10
+ console.log('Usage: lw destroy project-name');
11
+ console.log(`This will delete ${utils.dirs.src}/ ${utils.dirs.build}/ ${utils.dirs.dist}/ and ${utils.dirs.serve}/`)
12
+ return;
13
+ }
14
14
 
15
- const projectName = args[2];
15
+ const projectName = args[2];
16
16
 
17
- const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
17
+ const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
18
18
 
19
- if (projectName !== project.name) {
20
- console.error('Error: project name doesn\'t match.');
21
- return;
22
- }
19
+ if (projectName !== project.name) {
20
+ console.error('Error: project name doesn\'t match.');
21
+ return;
22
+ }
23
23
 
24
- fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
25
- fs.rmSync(utils.dirs.dist + '/', { recursive: true, force: true });
26
- fs.rmSync(utils.dirs.src + '/', { recursive: true, force: true });
27
- fs.rmSync(utils.dirs.serve + '/', { recursive: true, force: true });
28
- fs.rmSync(utils.dirs.electron + '/', { recursive: true, force: true });
24
+ fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
25
+ fs.rmSync(utils.dirs.dist + '/', { recursive: true, force: true });
26
+ fs.rmSync(utils.dirs.src + '/', { recursive: true, force: true });
27
+ fs.rmSync(utils.dirs.serve + '/', { recursive: true, force: true });
29
28
  })();
package/commands/dist.js CHANGED
@@ -1,72 +1,58 @@
1
- import webpack from 'webpack';
1
+ import { createRequire } from "module";
2
+ const require = createRequire(import.meta.url);
3
+
2
4
  import * as utils from './utils.js';
3
5
  import fs from 'fs';
4
6
  import fse from 'fs-extra';
5
7
  import { minify } from 'html-minifier';
6
8
  import CleanCSS from 'clean-css';
7
9
 
8
- import { createRequire } from "module";
9
- const require = createRequire(import.meta.url);
10
+ import esbuild from 'esbuild';
10
11
 
11
12
  let env = '';
12
13
  const args = process.argv;
13
14
  if (args.length >= 3) {
14
- env = args[2];
15
+ env = args[2];
15
16
  }
16
17
 
17
18
  (async () => {
18
- const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
19
-
20
- await utils.exec(`npx leanweb clean`);
21
- await utils.exec(`npx leanweb build ${env}`);
22
-
23
- const webpackConfig = utils.getWebPackConfig(utils.dirs.dist, project);
24
-
25
- const compiler = webpack({
26
- ...webpackConfig,
27
- mode: 'production',
28
- devtool: 'source-map',
29
- performance: {
30
- hints: false,
31
- },
32
- });
33
-
34
- compiler.run(async (err, stats) => {
35
- if (err) {
36
- console.log(err);
37
- }
38
- if (stats.compilation.errors.length) {
39
- console.log(stats.compilation.errors);
40
- }
41
- if (stats.compilation.warnings.length) {
42
- console.log(stats.compilation.warnings);
43
- }
44
-
45
- const indexHTML = fs.readFileSync(`./${utils.dirs.build}/index.html`, 'utf8');
46
- const minifiedIndexHtml = minify(indexHTML, {
47
- caseSensitive: true,
48
- collapseWhitespace: true,
49
- minifyCSS: true,
50
- minifyJS: true,
51
- removeComments: true,
52
- });
53
- fs.writeFileSync(`./${utils.dirs.dist}/index.html`, minifiedIndexHtml);
54
-
55
- const appCSS = fs.readFileSync(`./${utils.dirs.build}/${project.name}.css`, 'utf8');
56
- const minifiedAppCss = new CleanCSS({}).minify(appCSS);
57
- fs.writeFileSync(`./${utils.dirs.dist}/${project.name}.css`, minifiedAppCss.styles);
58
-
59
- fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.dist}/favicon.svg`);
60
- project.resources?.forEach(resource => {
61
- const source = `./${utils.dirs.build}/${resource}`;
62
- if (fs.existsSync(source)) {
63
- fse.copySync(source, `./${utils.dirs.dist}/${resource}`, { dereference: true });
64
- }
65
- });
66
-
67
- const postDistFile = './post-dist';
68
- if (fs.existsSync(postDistFile) && fs.statSync(postDistFile).isFile()) {
69
- await utils.exec(postDistFile);
70
- }
71
- });
19
+ const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
20
+
21
+ await utils.exec(`npx leanweb clean`);
22
+ await utils.exec(`npx leanweb build ${env}`);
23
+
24
+ fs.mkdirSync(utils.dirs.dist, { recursive: true });
25
+ esbuild.build({
26
+ entryPoints: [`./${utils.dirs.build}/${project.name}.js`],
27
+ bundle: true,
28
+ format: 'esm',
29
+ outfile: `./${utils.dirs.dist}/${project.name}.js`,
30
+ }).catch(() => process.exit(1))
31
+
32
+ const indexHTML = fs.readFileSync(`./${utils.dirs.build}/index.html`, 'utf8');
33
+ const minifiedIndexHtml = minify(indexHTML, {
34
+ caseSensitive: true,
35
+ collapseWhitespace: true,
36
+ minifyCSS: true,
37
+ minifyJS: true,
38
+ removeComments: true,
39
+ });
40
+ fs.writeFileSync(`./${utils.dirs.dist}/index.html`, minifiedIndexHtml);
41
+
42
+ const appCSS = fs.readFileSync(`./${utils.dirs.build}/${project.name}.css`, 'utf8');
43
+ const minifiedAppCss = new CleanCSS({}).minify(appCSS);
44
+ fs.writeFileSync(`./${utils.dirs.dist}/${project.name}.css`, minifiedAppCss.styles);
45
+
46
+ fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.dist}/favicon.svg`);
47
+ project.resources?.forEach(resource => {
48
+ const source = `./${utils.dirs.build}/${resource}`;
49
+ if (fs.existsSync(source)) {
50
+ fse.copySync(source, `./${utils.dirs.dist}/${resource}`, { dereference: true });
51
+ }
52
+ });
53
+
54
+ const postDistFile = './post-dist';
55
+ if (fs.existsSync(postDistFile) && fs.statSync(postDistFile).isFile()) {
56
+ await utils.exec(postDistFile);
57
+ }
72
58
  })();
@@ -1,58 +1,57 @@
1
- import fs from 'fs';
2
- import * as utils from './utils.js';
3
-
4
1
  import path from 'path';
5
2
  import { fileURLToPath } from 'url';
6
3
  const __filename = fileURLToPath(import.meta.url);
7
4
  const __dirname = path.dirname(__filename);
8
-
9
5
  import { createRequire } from "module";
10
6
  const require = createRequire(import.meta.url);
11
7
 
8
+ import fs from 'fs';
9
+ import * as utils from './utils.js';
10
+
12
11
  (async () => {
13
- const args = process.argv;
14
- if (args.length < 3) {
15
- console.error('Usage: lw generate component-names');
16
- return;
17
- }
18
-
19
- const leanwebJSONPath = `${process.cwd()}/${utils.dirs.src}/leanweb.json`;
20
- const leanwebJSON = require(leanwebJSONPath);
21
- const cmps = args.slice(2);
22
-
23
- for (const cmpJSON of leanwebJSON.components) {
24
- for (const cmp of cmps) {
25
- if (cmpJSON === cmp) {
26
- console.error(`Error: component ${cmpJSON} existed.`);
27
- return;
28
- }
12
+ const args = process.argv;
13
+ if (args.length < 3) {
14
+ console.error('Usage: lw generate component-names');
15
+ return;
16
+ }
17
+
18
+ const leanwebJSONPath = `${process.cwd()}/${utils.dirs.src}/leanweb.json`;
19
+ const leanwebJSON = require(leanwebJSONPath);
20
+ const cmps = args.slice(2);
21
+
22
+ for (const cmpJSON of leanwebJSON.components) {
23
+ for (const cmp of cmps) {
24
+ if (cmpJSON === cmp) {
25
+ console.error(`Error: component ${cmpJSON} existed.`);
26
+ return;
29
27
  }
30
- }
28
+ }
29
+ }
31
30
 
32
- leanwebJSON.components.push(...cmps);
33
- fs.writeFileSync(leanwebJSONPath, JSON.stringify(leanwebJSON, null, 2));
31
+ leanwebJSON.components.push(...cmps);
32
+ fs.writeFileSync(leanwebJSONPath, JSON.stringify(leanwebJSON, null, 2));
34
33
 
35
- for (const cmp of cmps) {
36
- const cmpName = utils.getComponentName(cmp);
37
- const cmpPath = `${utils.dirs.src}/components/${cmp}`;
34
+ for (const cmp of cmps) {
35
+ const cmpName = utils.getComponentName(cmp);
36
+ const cmpPath = `${utils.dirs.src}/components/${cmp}`;
38
37
 
39
- fs.mkdirSync(cmpPath, { recursive: true });
38
+ fs.mkdirSync(cmpPath, { recursive: true });
40
39
 
41
- if (!fs.existsSync(`${cmpPath}/${cmpName}.js`)) {
42
- let jsString = fs.readFileSync(`${__dirname}/../templates/component.js`, 'utf8');
43
- jsString = jsString.replace(/\$\{projectName\}/g, leanwebJSON.name);
44
- jsString = jsString.replace(/\$\{component\}/g, cmp.replace(/\//g, '-'));
45
- jsString = jsString.replace(/\$\{pathLevels\}/g, utils.getPathLevels(cmp));
40
+ if (!fs.existsSync(`${cmpPath}/${cmpName}.js`)) {
41
+ let jsString = fs.readFileSync(`${__dirname}/../templates/component.js`, 'utf8');
42
+ jsString = jsString.replace(/\$\{projectName\}/g, leanwebJSON.name);
43
+ jsString = jsString.replace(/\$\{component\}/g, cmp.replace(/\//g, '-'));
44
+ jsString = jsString.replace(/\$\{pathLevels\}/g, utils.getPathLevels(cmp));
46
45
 
47
- fs.writeFileSync(`${cmpPath}/${cmpName}.js`, jsString);
48
- }
46
+ fs.writeFileSync(`${cmpPath}/${cmpName}.js`, jsString);
47
+ }
49
48
 
50
- if (!fs.existsSync(`${cmpPath}/${cmpName}.html`)) {
51
- fs.writeFileSync(`${cmpPath}/${cmpName}.html`, `<div>${leanwebJSON.name}-${cmpName} works!</div>`);
52
- }
49
+ if (!fs.existsSync(`${cmpPath}/${cmpName}.html`)) {
50
+ fs.writeFileSync(`${cmpPath}/${cmpName}.html`, `<div>${leanwebJSON.name}-${cmpName} works!</div>`);
51
+ }
53
52
 
54
- if (!fs.existsSync(`${cmpPath}/${cmpName}.scss`)) {
55
- fs.writeFileSync(`${cmpPath}/${cmpName}.scss`, '');
56
- }
57
- }
53
+ if (!fs.existsSync(`${cmpPath}/${cmpName}.scss`)) {
54
+ fs.writeFileSync(`${cmpPath}/${cmpName}.scss`, '');
55
+ }
56
+ }
58
57
  })();
package/commands/help.js CHANGED
@@ -1,31 +1,31 @@
1
1
  import * as utils from './utils.js';
2
2
 
3
3
  (async () => {
4
- if (process.argv.length < 3) {
5
- utils.exec('npx leanweb version');
6
- console.log('Usage: lw target parameters');
7
- console.log('Targets:\n');
8
- Object.keys(utils.targets).forEach(t => {
9
- console.log(t);
10
- });
11
- console.log();
12
- return;
13
- }
4
+ if (process.argv.length < 3) {
5
+ utils.exec('npx leanweb version');
6
+ console.log('Usage: lw target parameters');
7
+ console.log('Targets:\n');
8
+ Object.keys(utils.targets).forEach(t => {
9
+ console.log(t);
10
+ });
11
+ console.log();
12
+ return;
13
+ }
14
14
 
15
- let target = process.argv[2];
15
+ let target = process.argv[2];
16
16
 
17
- const targetCandidates = Object.keys(utils.targets).filter(t => t.startsWith(target));
17
+ const targetCandidates = Object.keys(utils.targets).filter(t => t.startsWith(target));
18
18
 
19
- if (targetCandidates.length === 0) {
20
- console.error(`Error: target ${target} not found.`);
21
- return;
22
- } else if (targetCandidates.length > 1) {
23
- targetCandidates.forEach(t => {
24
- console.log(t);
25
- });
26
- return;
27
- }
19
+ if (targetCandidates.length === 0) {
20
+ console.error(`Error: target ${target} not found.`);
21
+ return;
22
+ } else if (targetCandidates.length > 1) {
23
+ targetCandidates.forEach(t => {
24
+ console.log(t);
25
+ });
26
+ return;
27
+ }
28
28
 
29
- target = targetCandidates[0];
30
- console.log(utils.targets[target].note);
29
+ target = targetCandidates[0];
30
+ console.log(utils.targets[target].note);
31
31
  })();