leanweb 1.1.0 → 1.1.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/commands/build.js CHANGED
@@ -1,10 +1,17 @@
1
- (async () => {
2
- const fs = require('fs');
3
- const path = require('path');
4
- const fse = require('fs-extra');
5
- const utils = require('./utils.js');
6
- const parser = require('../lib/lw-html-parser.js');
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) {
@@ -50,12 +57,12 @@
50
57
  // }
51
58
  // };
52
59
 
53
- const buildDirFilter = dirPath => {
54
- if (dirPath.startsWith(`${utils.dirs.build}/lib/`)) {
55
- return false;
56
- }
57
- return true;
58
- };
60
+ // const buildDirFilter = dirPath => {
61
+ // if (dirPath.startsWith(`${utils.dirs.build}/lib/`)) {
62
+ // return false;
63
+ // }
64
+ // return true;
65
+ // };
59
66
 
60
67
  const leanwebPackageJSON = require(`${__dirname}/../package.json`);
61
68
 
package/commands/clean.js CHANGED
@@ -1,5 +1,5 @@
1
- const fs = require('fs');
2
- const utils = require('./utils.js');
1
+ import fs from 'fs';
2
+ import * as utils from './utils.js';
3
3
 
4
4
  (async () => {
5
5
  fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
@@ -1,24 +1,29 @@
1
- const fs = require('fs');
2
- const utils = require('./utils.js');
1
+ import fs from 'fs';
2
+ import * as utils from './utils.js';
3
3
 
4
- const args = process.argv;
5
- if (args.length < 3) {
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
- const projectName = args[2];
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 project = require(`${process.cwd()}/${utils.dirs.src}/leanweb.json`);
15
+ const projectName = args[2];
14
16
 
15
- if (projectName !== project.name) {
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
- fs.rmSync(utils.dirs.build + '/', { recursive: true, force: true });
21
- fs.rmSync(utils.dirs.dist + '/', { recursive: true, force: true });
22
- fs.rmSync(utils.dirs.src + '/', { recursive: true, force: true });
23
- fs.rmSync(utils.dirs.serve + '/', { recursive: true, force: true });
24
- fs.rmSync(utils.dirs.electron + '/', { recursive: true, force: true });
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
- const webpack = require('webpack');
2
- const utils = require('./utils.js');
3
- const fs = require('fs');
4
- const fse = require('fs-extra');
5
- const minify = require('html-minifier').minify;
6
- const CleanCSS = require('clean-css');
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;
@@ -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) {
@@ -1,7 +1,15 @@
1
- (async () => {
2
- const fs = require('fs');
3
- const utils = require('./utils.js');
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
@@ -1,7 +1,6 @@
1
- (async () => {
2
-
3
- const utils = require('./utils.js');
1
+ import * as utils from './utils.js';
4
2
 
3
+ (async () => {
5
4
  if (process.argv.length < 3) {
6
5
  utils.exec('npx lw version');
7
6
  console.log('Usage: lw target parameters');
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
- const fse = require('fs-extra');
2
- const utils = require('./utils.js');
3
- const webpack = require('webpack');
4
- const watch = require('node-watch');
5
- const WebpackDevServer = require('webpack-dev-server');
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;
@@ -1,7 +1,15 @@
1
- const semver = require('semver');
2
- const fs = require('fs');
3
- const fse = require('fs-extra');
4
- const utils = require('./utils.js');
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,11 +1,19 @@
1
- const { execSync } = require('child_process');
2
- const sass = require('sass');
3
- const path = require('path');
4
- const net = require('net');
5
-
6
- const fse = require('fs-extra');
7
-
8
- const dirs = {
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 = {
9
17
  src: 'src',
10
18
  build: 'build',
11
19
  serve: 'serve',
@@ -13,14 +21,14 @@ const dirs = {
13
21
  electron: 'electron',
14
22
  };
15
23
 
16
- module.exports.copySymbolLinkFilter = (src, dest) => {
24
+ export const copySymbolLinkFilter = (src, dest) => {
17
25
  const destStats = fse.existsSync(dest) && fse.lstatSync(dest);
18
26
  return !destStats?.isSymbolicLink?.();
19
27
  };
20
28
 
21
- module.exports.exec = command => execSync(command, { encoding: 'utf8', stdio: 'inherit' });
29
+ export const exec = command => execSync(command, { encoding: 'utf8', stdio: 'inherit' });
22
30
 
23
- module.exports.buildCSS = (scssString, currentPaths) => {
31
+ export const buildCSS = (scssString, currentPaths) => {
24
32
  if (scssString.trim()) {
25
33
  const includePaths = [currentPaths, path.resolve(process.cwd(), dirs.build), path.resolve(process.cwd(), 'node_modules')];
26
34
  const cssResult = sass.renderSync({ data: scssString, includePaths });
@@ -29,7 +37,7 @@ module.exports.buildCSS = (scssString, currentPaths) => {
29
37
  return '';
30
38
  };
31
39
 
32
- module.exports.getComponentName = cmp => {
40
+ export const getComponentName = cmp => {
33
41
  const indexOfLastSlash = cmp.lastIndexOf('/');
34
42
  if (indexOfLastSlash > -1) {
35
43
  return cmp.substring(indexOfLastSlash + 1);
@@ -37,7 +45,7 @@ module.exports.getComponentName = cmp => {
37
45
  return cmp;
38
46
  };
39
47
 
40
- module.exports.getPathLevels = filePath => {
48
+ export const getPathLevels = filePath => {
41
49
  filePath = path.normalize(filePath);
42
50
  const numSlashes = filePath.replace(/[^\/]/g, '').length;
43
51
  let ret = '';
@@ -47,7 +55,7 @@ module.exports.getPathLevels = filePath => {
47
55
  return ret;
48
56
  };
49
57
 
50
- module.exports.throttle = (callback, limit = 100) => {
58
+ export const throttle = (callback, limit = 100) => {
51
59
  let wait = false;
52
60
  return function () {
53
61
  if (!wait) {
@@ -60,7 +68,7 @@ module.exports.throttle = (callback, limit = 100) => {
60
68
  };
61
69
  };
62
70
 
63
- module.exports.getWebPackConfig = (outputDir, project) => {
71
+ export const getWebPackConfig = (outputDir, project) => {
64
72
  return {
65
73
  entry: process.cwd() + `/${dirs.build}/${project.name}.js`,
66
74
  output: {
@@ -113,7 +121,7 @@ module.exports.getWebPackConfig = (outputDir, project) => {
113
121
  }
114
122
  };
115
123
 
116
- module.exports.portInUse = (port, address = '127.0.0.1') => {
124
+ export const portInUse = (port, address = '127.0.0.1') => {
117
125
  return new Promise((resolve, reject) => {
118
126
  const server = net.createServer(socket => socket.pipe(socket));
119
127
 
@@ -128,8 +136,6 @@ module.exports.portInUse = (port, address = '127.0.0.1') => {
128
136
  });
129
137
  };
130
138
 
131
- module.exports.dirs = dirs;
132
-
133
139
  const initNote = `Usage: leanweb init or leanweb init project-name
134
140
  leanweb init will initialize a leanweb project with the name of the current
135
141
  working directory, otherwise, if a project-name is provided, the provided
@@ -229,7 +235,7 @@ leanweb generate login is the same as leanweb g login
229
235
  const versionNote = `Usage: leanweb version
230
236
  Print version information for leanweb.`;
231
237
 
232
- module.exports.targets = {
238
+ export const targets = {
233
239
  'init': { file: 'init.js', note: initNote },
234
240
  'generate': { file: 'generate.js', note: generateNote },
235
241
  'serve': { file: 'serve.js', note: serveNote },
@@ -1,2 +1,4 @@
1
+ import { createRequire } from "module";
2
+ const require = createRequire(import.meta.url);
1
3
  const packageJSON = require('../package.json');
2
4
  console.log(packageJSON.name, packageJSON.version);
package/leanweb.js CHANGED
@@ -1,10 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- (async () => {
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
- const fs = require('fs');
6
- const semver = require('semver');
7
- const utils = require('./commands/utils.js');
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
 
@@ -1,5 +1,5 @@
1
- const parse5 = require('parse5');
2
- const parser = require('@babel/parser');
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.1.0",
3
+ "version": "1.1.1",
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.7",
23
- "@babel/parser": "^7.16.8",
24
- "@babel/plugin-transform-runtime": "^7.16.8",
25
- "@babel/preset-env": "^7.16.8",
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
28
  "clean-css": "^5.2.2",
28
29
  "css-loader": "^6.5.1",
29
30
  "fs-extra": "^10.0.0",
30
- "globby": "^11.0.4",
31
+ "globby": "^13.0.0",
31
32
  "html-minifier": "^4.0.0",
32
- "isomorphic-git": "^1.10.4",
33
+ "isomorphic-git": "^1.10.5",
33
34
  "json5-loader": "^4.0.1",
34
- "node-watch": "^0.7.2",
35
+ "node-watch": "^0.7.3",
35
36
  "parse5": "^6.0.1",
36
37
  "raw-loader": "^4.0.2",
37
- "sass": "^1.48.0",
38
+ "sass": "^1.49.0",
38
39
  "sass-loader": "^12.4.0",
39
40
  "semver": "^7.3.5",
40
- "webpack": "^5.66.0",
41
+ "webpack": "^5.67.0",
41
42
  "webpack-dev-server": "^4.7.3"
42
43
  }
43
44
  }
@@ -1,4 +1,4 @@
1
- const { app, BrowserWindow } = require('electron');
1
+ import { app, BrowserWindow } from 'electron';
2
2
 
3
3
  const createWindow = () => {
4
4
  // Create the browser window.