leanweb 1.0.8 → 1.1.2
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 +2 -4
- package/commands/build.js +60 -48
- package/commands/clean.js +2 -2
- package/commands/destroy.js +24 -19
- package/commands/dist.js +11 -7
- package/commands/electron.js +15 -6
- package/commands/generate.js +11 -3
- package/commands/help.js +2 -3
- package/commands/init.js +14 -6
- package/commands/serve.js +9 -6
- package/commands/upgrade.js +12 -4
- package/commands/utils.js +30 -17
- package/commands/version.js +2 -0
- package/leanweb.js +12 -4
- package/lib/lw-html-parser.js +3 -5
- package/package.json +14 -13
- package/templates/electron.js +1 -1
package/README.md
CHANGED
|
@@ -476,9 +476,7 @@ Assuming npm module `lodash-es` is installed, you could use any of the
|
|
|
476
476
|
following `import` statements for your web component class:
|
|
477
477
|
|
|
478
478
|
```javascript
|
|
479
|
-
import
|
|
480
|
-
import get from "lodash-es/get.js"; // find from node_modules
|
|
481
|
-
import * as _ from "lodash-es"; // find from node_modules
|
|
479
|
+
import get from "/node_modules/lodash-es/get.js"; // find from node_modules
|
|
482
480
|
```
|
|
483
481
|
|
|
484
482
|
Importing a JSON file:
|
|
@@ -490,7 +488,7 @@ import someJSON from "./some.json";
|
|
|
490
488
|
Importing CSS/SCSS:
|
|
491
489
|
|
|
492
490
|
```javascript
|
|
493
|
-
import agate from "highlight.js/scss/agate.scss";
|
|
491
|
+
import agate from "/node_modules/highlight.js/scss/agate.scss";
|
|
494
492
|
|
|
495
493
|
// customElements.define('demo-root',
|
|
496
494
|
// class extends LWElement { // LWElement extends HTMLElement
|
package/commands/build.js
CHANGED
|
@@ -1,56 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import * as utils from './utils.js';
|
|
4
|
+
import * as parser from '../lib/lw-html-parser.js';
|
|
5
|
+
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
7
10
|
|
|
11
|
+
import { createRequire } from "module";
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
8
15
|
let env;
|
|
9
16
|
const args = process.argv;
|
|
10
17
|
if (args.length >= 3) {
|
|
11
18
|
env = args[2];
|
|
12
19
|
}
|
|
13
20
|
|
|
14
|
-
const replaceNodeModulesImport = (str, filePath) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const walkDirSync = (dir, accept = null, callback) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const preprocessJsImport = filePath => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
21
|
+
// const replaceNodeModulesImport = (str, filePath) => {
|
|
22
|
+
// // match import not starting with dot or slash
|
|
23
|
+
// return str.replace(/^([^\S\r\n]*(?:importScripts|import).+?['"])((?!\.|\/|http\:|https\:).*?)(['"].*)$/gm, (m, a, b, c) => {
|
|
24
|
+
// if (b.startsWith(`~`)) {
|
|
25
|
+
// // ~/package.json
|
|
26
|
+
// return a + path.normalize(`${process.cwd()}/` + b.substring(1)) + c;
|
|
27
|
+
// } else if (b.indexOf('/') > -1) {
|
|
28
|
+
// // lodash-es/get.js
|
|
29
|
+
// return a + path.normalize(`${process.cwd()}/node_modules/` + b) + c;
|
|
30
|
+
// } else {
|
|
31
|
+
// const nodeModulePath = `${process.cwd()}/node_modules/` + b + '/package.json';
|
|
32
|
+
// const package = require(nodeModulePath);
|
|
33
|
+
// // lodash-es
|
|
34
|
+
// return a + path.normalize(`${process.cwd()}/node_modules/` + b + '/' + package.main) + c;
|
|
35
|
+
// }
|
|
36
|
+
// });
|
|
37
|
+
// };
|
|
38
|
+
|
|
39
|
+
// const walkDirSync = (dir, accept = null, callback) => {
|
|
40
|
+
// fs.readdirSync(dir).forEach(f => {
|
|
41
|
+
// let dirPath = path.join(dir, f);
|
|
42
|
+
// const isDirectory = fs.statSync(dirPath).isDirectory() && (!accept || (typeof accept === 'function' && accept(dirPath, f)));
|
|
43
|
+
// isDirectory ? walkDirSync(dirPath, accept, callback) : callback(path.join(dirPath));
|
|
44
|
+
// });
|
|
45
|
+
// };
|
|
46
|
+
|
|
47
|
+
// const preprocessJsImport = filePath => {
|
|
48
|
+
// if (
|
|
49
|
+
// filePath.toLowerCase().endsWith('.js') &&
|
|
50
|
+
// !filePath.toLowerCase().endsWith('/ast.js') &&
|
|
51
|
+
// !filePath.startsWith(`${utils.dirs.build}/lib/`) &&
|
|
52
|
+
// !filePath.startsWith(`${utils.dirs.build}/resources/`)
|
|
53
|
+
// ) {
|
|
54
|
+
// let jsFileString = fs.readFileSync(filePath, 'utf8');
|
|
55
|
+
// jsFileString = replaceNodeModulesImport(jsFileString, filePath);
|
|
56
|
+
// fs.writeFileSync(filePath, jsFileString);
|
|
57
|
+
// }
|
|
58
|
+
// };
|
|
59
|
+
|
|
60
|
+
// const buildDirFilter = dirPath => {
|
|
61
|
+
// if (dirPath.startsWith(`${utils.dirs.build}/lib/`)) {
|
|
62
|
+
// return false;
|
|
63
|
+
// }
|
|
64
|
+
// return true;
|
|
65
|
+
// };
|
|
54
66
|
|
|
55
67
|
const leanwebPackageJSON = require(`${__dirname}/../package.json`);
|
|
56
68
|
|
|
@@ -86,7 +98,7 @@
|
|
|
86
98
|
});
|
|
87
99
|
|
|
88
100
|
const copySrc = () => {
|
|
89
|
-
fse.copySync(`${projectPath}/${utils.dirs.src}/`, buildDir, {
|
|
101
|
+
fse.copySync(`${projectPath}/${utils.dirs.src}/`, buildDir, { filter: utils.copySymbolLinkFilter });
|
|
90
102
|
};
|
|
91
103
|
|
|
92
104
|
const copyEnv = () => {
|
|
@@ -96,7 +108,7 @@
|
|
|
96
108
|
};
|
|
97
109
|
|
|
98
110
|
const buildJS = () => {
|
|
99
|
-
walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
|
|
111
|
+
// walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
|
|
100
112
|
|
|
101
113
|
const jsString = project.components.reduce((acc, cur) => {
|
|
102
114
|
const cmpName = utils.getComponentName(cur);
|
package/commands/clean.js
CHANGED
package/commands/destroy.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as utils from './utils.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
console.log('Usage: lw destroy project-name');
|
|
7
|
-
console.log(`This will delete ${utils.dirs.src}/ ${utils.dirs.build}/ ${utils.dirs.dist}/ ${utils.dirs.serve}/ and ${utils.dirs.electron}/`)
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
10
6
|
|
|
11
|
-
|
|
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
|
+
}
|
|
12
14
|
|
|
13
|
-
const
|
|
15
|
+
const projectName = args[2];
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
console.error('Error: project name doesn\'t match.');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
17
|
+
const project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (projectName !== project.name) {
|
|
20
|
+
console.error('Error: project name doesn\'t match.');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
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 });
|
|
29
|
+
})();
|
package/commands/dist.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const minify = require('html-minifier').minify;
|
|
6
|
-
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import * as utils from './utils.js';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import fse from 'fs-extra';
|
|
5
|
+
// const minify = require('html-minifier').minify;
|
|
6
|
+
import { minify } from 'html-minifier';
|
|
7
|
+
import CleanCSS from 'clean-css';
|
|
8
|
+
|
|
9
|
+
import { createRequire } from "module";
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
7
11
|
|
|
8
12
|
let env = '';
|
|
9
13
|
const args = process.argv;
|
|
@@ -54,7 +58,7 @@ if (args.length >= 3) {
|
|
|
54
58
|
fs.writeFileSync(`./${utils.dirs.dist}/${project.name}.css`, minifiedAppCss.styles);
|
|
55
59
|
|
|
56
60
|
fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.dist}/favicon.svg`);
|
|
57
|
-
project.resources
|
|
61
|
+
project.resources?.forEach(resource => {
|
|
58
62
|
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.dist}/${resource}`, { dereference: true });
|
|
59
63
|
});
|
|
60
64
|
});
|
package/commands/electron.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
(async () => {
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
const webpack = require('webpack');
|
|
5
|
-
const utils = require('./utils.js');
|
|
6
1
|
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import webpack from 'webpack';
|
|
5
|
+
import * as utils from './utils.js';
|
|
6
|
+
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
|
|
15
|
+
(async () => {
|
|
7
16
|
let env = '';
|
|
8
17
|
const args = process.argv;
|
|
9
18
|
if (args.length >= 3) {
|
|
@@ -29,7 +38,7 @@
|
|
|
29
38
|
fse.copySync(`./${utils.dirs.build}/index.html`, `./${utils.dirs.electron}/index.html`);
|
|
30
39
|
fse.copySync(`./${utils.dirs.build}/${project.name}.css`, `./${utils.dirs.electron}/${project.name}.css`);
|
|
31
40
|
fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.electron}/favicon.svg`);
|
|
32
|
-
project.resources
|
|
41
|
+
project.resources?.forEach(resource => {
|
|
33
42
|
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.electron}/${resource}`, { dereference: true });
|
|
34
43
|
});
|
|
35
44
|
|
package/commands/generate.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as utils from './utils.js';
|
|
3
|
+
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
4
8
|
|
|
9
|
+
import { createRequire } from "module";
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
5
13
|
const args = process.argv;
|
|
6
14
|
if (args.length < 3) {
|
|
7
15
|
console.error('Usage: lw generate component-names');
|
package/commands/help.js
CHANGED
package/commands/init.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import git from 'isomorphic-git';
|
|
4
|
+
import globby from 'globby';
|
|
5
|
+
import * as utils from './utils.js';
|
|
6
|
+
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
|
|
12
|
+
import { createRequire } from "module";
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
14
|
+
|
|
1
15
|
(async () => {
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const fse = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const git = require('isomorphic-git');
|
|
6
|
-
const globby = require('globby');
|
|
7
16
|
const args = process.argv;
|
|
8
|
-
const utils = require('./utils.js');
|
|
9
17
|
|
|
10
18
|
const leanwebJSONExisted = fs.existsSync(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
|
|
11
19
|
const packageJSONExisted = fs.existsSync(`${process.cwd()}/package.json`);
|
package/commands/serve.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import * as utils from './utils.js';
|
|
3
|
+
import webpack from 'webpack';
|
|
4
|
+
import watch from 'node-watch';
|
|
5
|
+
import WebpackDevServer from 'webpack-dev-server';
|
|
6
|
+
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
6
9
|
|
|
7
10
|
let env = '';
|
|
8
11
|
const args = process.argv;
|
|
@@ -26,7 +29,7 @@ const noopen = process.env.noopen || false;
|
|
|
26
29
|
fse.copySync(`./${utils.dirs.build}/${project.name}.css`, `./${utils.dirs.serve}/${project.name}.css`);
|
|
27
30
|
fse.copySync(`./${utils.dirs.build}/favicon.svg`, `./${utils.dirs.serve}/favicon.svg`);
|
|
28
31
|
project.resources?.forEach(resource => {
|
|
29
|
-
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.serve}/${resource}`, {
|
|
32
|
+
fse.copySync(`./${utils.dirs.build}/${resource}`, `./${utils.dirs.serve}/${resource}`, { filter: utils.copySymbolLinkFilter });
|
|
30
33
|
});
|
|
31
34
|
} catch (e) {
|
|
32
35
|
console.error(e);
|
package/commands/upgrade.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import fse from 'fs-extra';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import * as utils from './utils.js';
|
|
5
|
+
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
import { createRequire } from "module";
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
5
13
|
|
|
6
14
|
const leanwebPackageJSON = require(`${__dirname}/../package.json`);
|
|
7
15
|
const projectLeanwebJSON = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
|
package/commands/utils.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
const { execSync } = require('child_process');
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// const { execSync } = require('child_process');
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
// const sass = require('sass');
|
|
4
|
+
import sass from 'sass';
|
|
5
|
+
// import path from 'path';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
// const net = require('net');
|
|
8
|
+
import net from 'net';
|
|
9
|
+
|
|
10
|
+
// import fse from 'fs-extra';
|
|
11
|
+
import fse from 'fs-extra';
|
|
12
|
+
|
|
13
|
+
import { createRequire } from "module";
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
|
|
16
|
+
export const dirs = {
|
|
7
17
|
src: 'src',
|
|
8
18
|
build: 'build',
|
|
9
19
|
serve: 'serve',
|
|
@@ -11,9 +21,14 @@ const dirs = {
|
|
|
11
21
|
electron: 'electron',
|
|
12
22
|
};
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
export const copySymbolLinkFilter = (src, dest) => {
|
|
25
|
+
const destStats = fse.existsSync(dest) && fse.lstatSync(dest);
|
|
26
|
+
return !destStats?.isSymbolicLink?.();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const exec = command => execSync(command, { encoding: 'utf8', stdio: 'inherit' });
|
|
15
30
|
|
|
16
|
-
|
|
31
|
+
export const buildCSS = (scssString, currentPaths) => {
|
|
17
32
|
if (scssString.trim()) {
|
|
18
33
|
const includePaths = [currentPaths, path.resolve(process.cwd(), dirs.build), path.resolve(process.cwd(), 'node_modules')];
|
|
19
34
|
const cssResult = sass.renderSync({ data: scssString, includePaths });
|
|
@@ -22,7 +37,7 @@ module.exports.buildCSS = (scssString, currentPaths) => {
|
|
|
22
37
|
return '';
|
|
23
38
|
};
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
export const getComponentName = cmp => {
|
|
26
41
|
const indexOfLastSlash = cmp.lastIndexOf('/');
|
|
27
42
|
if (indexOfLastSlash > -1) {
|
|
28
43
|
return cmp.substring(indexOfLastSlash + 1);
|
|
@@ -30,7 +45,7 @@ module.exports.getComponentName = cmp => {
|
|
|
30
45
|
return cmp;
|
|
31
46
|
};
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
export const getPathLevels = filePath => {
|
|
34
49
|
filePath = path.normalize(filePath);
|
|
35
50
|
const numSlashes = filePath.replace(/[^\/]/g, '').length;
|
|
36
51
|
let ret = '';
|
|
@@ -40,7 +55,7 @@ module.exports.getPathLevels = filePath => {
|
|
|
40
55
|
return ret;
|
|
41
56
|
};
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
export const throttle = (callback, limit = 100) => {
|
|
44
59
|
let wait = false;
|
|
45
60
|
return function () {
|
|
46
61
|
if (!wait) {
|
|
@@ -53,7 +68,7 @@ module.exports.throttle = (callback, limit = 100) => {
|
|
|
53
68
|
};
|
|
54
69
|
};
|
|
55
70
|
|
|
56
|
-
|
|
71
|
+
export const getWebPackConfig = (outputDir, project) => {
|
|
57
72
|
return {
|
|
58
73
|
entry: process.cwd() + `/${dirs.build}/${project.name}.js`,
|
|
59
74
|
output: {
|
|
@@ -73,7 +88,7 @@ module.exports.getWebPackConfig = (outputDir, project) => {
|
|
|
73
88
|
}]
|
|
74
89
|
},
|
|
75
90
|
}, {
|
|
76
|
-
test: /\.(scss|sass)$/i,
|
|
91
|
+
test: /\.(scss|sass|css)$/i,
|
|
77
92
|
use: [
|
|
78
93
|
{
|
|
79
94
|
loader: require.resolve('css-loader'),
|
|
@@ -106,7 +121,7 @@ module.exports.getWebPackConfig = (outputDir, project) => {
|
|
|
106
121
|
}
|
|
107
122
|
};
|
|
108
123
|
|
|
109
|
-
|
|
124
|
+
export const portInUse = (port, address = '127.0.0.1') => {
|
|
110
125
|
return new Promise((resolve, reject) => {
|
|
111
126
|
const server = net.createServer(socket => socket.pipe(socket));
|
|
112
127
|
|
|
@@ -121,8 +136,6 @@ module.exports.portInUse = (port, address = '127.0.0.1') => {
|
|
|
121
136
|
});
|
|
122
137
|
};
|
|
123
138
|
|
|
124
|
-
module.exports.dirs = dirs;
|
|
125
|
-
|
|
126
139
|
const initNote = `Usage: leanweb init or leanweb init project-name
|
|
127
140
|
leanweb init will initialize a leanweb project with the name of the current
|
|
128
141
|
working directory, otherwise, if a project-name is provided, the provided
|
|
@@ -222,7 +235,7 @@ leanweb generate login is the same as leanweb g login
|
|
|
222
235
|
const versionNote = `Usage: leanweb version
|
|
223
236
|
Print version information for leanweb.`;
|
|
224
237
|
|
|
225
|
-
|
|
238
|
+
export const targets = {
|
|
226
239
|
'init': { file: 'init.js', note: initNote },
|
|
227
240
|
'generate': { file: 'generate.js', note: generateNote },
|
|
228
241
|
'serve': { file: 'serve.js', note: serveNote },
|
package/commands/version.js
CHANGED
package/leanweb.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import * as utils from './commands/utils.js';
|
|
6
|
+
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
|
|
15
|
+
(async () => {
|
|
8
16
|
|
|
9
17
|
const args = process.argv;
|
|
10
18
|
|
package/lib/lw-html-parser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as parse5 from 'parse5';
|
|
2
|
+
import * as parser from '@babel/parser';
|
|
3
3
|
|
|
4
4
|
let astKey = 0;
|
|
5
5
|
|
|
@@ -91,7 +91,7 @@ const walkNode = (node, interpolation) => {
|
|
|
91
91
|
node.childNodes && node.childNodes.forEach(childNode => walkNode(childNode, interpolation));
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
const parse = html => {
|
|
94
|
+
export const parse = html => {
|
|
95
95
|
const ast = {};
|
|
96
96
|
const doc = parse5.parseFragment(html, { sourceCodeLocationInfo: true });
|
|
97
97
|
walkNode(doc, ast);
|
|
@@ -100,8 +100,6 @@ const parse = html => {
|
|
|
100
100
|
return ast;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
module.exports = { parse };
|
|
104
|
-
|
|
105
103
|
|
|
106
104
|
// const html = `<div>
|
|
107
105
|
// <span class="x" lw>/a/;(1+(2+3))</span>
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "leanweb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Builds framework agnostic web components.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"leanweb": "leanweb.js",
|
|
7
7
|
"lw": "leanweb.js"
|
|
8
8
|
},
|
|
9
|
+
"type": "module",
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
12
|
"url": "git+https://github.com/elgs/leanweb.git"
|
|
@@ -19,25 +20,25 @@
|
|
|
19
20
|
"author": "Qian Chen",
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@babel/core": "^7.16.
|
|
23
|
-
"@babel/parser": "^7.16.
|
|
24
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
25
|
-
"@babel/preset-env": "^7.16.
|
|
23
|
+
"@babel/core": "^7.16.12",
|
|
24
|
+
"@babel/parser": "^7.16.12",
|
|
25
|
+
"@babel/plugin-transform-runtime": "^7.16.10",
|
|
26
|
+
"@babel/preset-env": "^7.16.11",
|
|
26
27
|
"babel-loader": "^8.2.3",
|
|
27
|
-
"clean-css": "^5.2.
|
|
28
|
+
"clean-css": "^5.2.4",
|
|
28
29
|
"css-loader": "^6.5.1",
|
|
29
30
|
"fs-extra": "^10.0.0",
|
|
30
|
-
"globby": "^
|
|
31
|
+
"globby": "^13.1.0",
|
|
31
32
|
"html-minifier": "^4.0.0",
|
|
32
|
-
"isomorphic-git": "^1.
|
|
33
|
+
"isomorphic-git": "^1.11.1",
|
|
33
34
|
"json5-loader": "^4.0.1",
|
|
34
|
-
"node-watch": "^0.7.
|
|
35
|
+
"node-watch": "^0.7.3",
|
|
35
36
|
"parse5": "^6.0.1",
|
|
36
37
|
"raw-loader": "^4.0.2",
|
|
37
|
-
"sass": "^1.
|
|
38
|
+
"sass": "^1.49.0",
|
|
38
39
|
"sass-loader": "^12.4.0",
|
|
39
40
|
"semver": "^7.3.5",
|
|
40
|
-
"webpack": "^5.
|
|
41
|
-
"webpack-dev-server": "^4.7.
|
|
41
|
+
"webpack": "^5.67.0",
|
|
42
|
+
"webpack-dev-server": "^4.7.3"
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|
package/templates/electron.js
CHANGED