leanweb 1.1.3 → 1.1.7

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
@@ -18,52 +18,6 @@ const require = createRequire(import.meta.url);
18
18
  env = args[2];
19
19
  }
20
20
 
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
- // };
66
-
67
21
  const leanwebPackageJSON = require(`${__dirname}/../package.json`);
68
22
 
69
23
  const buildModule = (projectPath) => {
@@ -108,8 +62,6 @@ const require = createRequire(import.meta.url);
108
62
  };
109
63
 
110
64
  const buildJS = () => {
111
- // walkDirSync(buildDir, buildDirFilter, preprocessJsImport);
112
-
113
65
  const jsString = project.components.reduce((acc, cur) => {
114
66
  const cmpName = utils.getComponentName(cur);
115
67
  let importString = `import './components/${cur}/${cmpName}.js';`;
@@ -121,18 +73,18 @@ const require = createRequire(import.meta.url);
121
73
  const buildHTML = () => {
122
74
  project.components.forEach(cmp => {
123
75
  const cmpName = utils.getComponentName(cmp);
124
- const htmlFilename = `${projectPath}/${buildDir}/components/${cmp}/${cmpName}.html`;
76
+ const htmlFilename = `${buildDir}/components/${cmp}/${cmpName}.html`;
125
77
  const htmlFileExists = fs.existsSync(htmlFilename);
126
78
  if (htmlFileExists) {
127
79
 
128
- const scssFilename = `${projectPath}/${buildDir}/components/${cmp}/${cmpName}.scss`;
80
+ const scssFilename = `${buildDir}/components/${cmp}/${cmpName}.scss`;
129
81
  const scssFileExists = fs.existsSync(scssFilename);
130
82
  let cssString = '';
131
83
  if (scssFileExists) {
132
- let scssString = `@use "global-styles.scss";\n`;
84
+ let scssString = `@use "${buildDir}/global-styles.scss";\n`;
133
85
  scssString += fs.readFileSync(scssFilename, 'utf8');
134
86
  scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
135
- cssString = utils.buildCSS(scssString, `${projectPath}/${buildDir}/components/${cmp}`);
87
+ cssString = utils.buildCSS(scssString, `${buildDir}/components/${cmp}`);
136
88
  }
137
89
  const styleString = cssString || '';
138
90
  const htmlString = fs.readFileSync(htmlFilename, 'utf8');
@@ -144,16 +96,16 @@ const require = createRequire(import.meta.url);
144
96
  fs.writeFileSync(`${buildDir}/components/${cmp}/ast.js`, `export default ${JSON.stringify(ast, null, 0)};`);
145
97
  }
146
98
  });
147
- const htmlString = fs.readFileSync(`${projectPath}/${buildDir}/index.html`, 'utf8');
99
+ const htmlString = fs.readFileSync(`${buildDir}/index.html`, 'utf8');
148
100
  fs.writeFileSync(`${buildDir}/index.html`, htmlString);
149
101
  };
150
102
 
151
103
  const buildSCSS = () => {
152
- const projectScssFilename = `${projectPath}/src/${project.name}.scss`;
104
+ const projectScssFilename = `${projectPath}/${utils.dirs.src}/${project.name}.scss`;
153
105
  let projectCssString = '';
154
106
  if (fs.existsSync(projectScssFilename)) {
155
107
  const projectScssString = fs.readFileSync(projectScssFilename, 'utf8');
156
- projectCssString += utils.buildCSS(projectScssString, `${projectPath}/${buildDir}`);
108
+ projectCssString += utils.buildCSS(projectScssString, buildDir);
157
109
  }
158
110
  fs.writeFileSync(`${buildDir}/${project.name}.css`, projectCssString);
159
111
  };
package/commands/init.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import fse from 'fs-extra';
3
3
  import git from 'isomorphic-git';
4
- import globby from 'globby';
4
+ import { globby } from 'globby';
5
5
  import * as utils from './utils.js';
6
6
 
7
7
  import path from 'path';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leanweb",
3
- "version": "1.1.3",
3
+ "version": "1.1.7",
4
4
  "description": "Builds framework agnostic web components.",
5
5
  "bin": {
6
6
  "leanweb": "leanweb.js",
@@ -20,25 +20,25 @@
20
20
  "author": "Qian Chen",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@babel/core": "^7.16.12",
24
- "@babel/parser": "^7.16.12",
25
- "@babel/plugin-transform-runtime": "^7.16.10",
23
+ "@babel/core": "^7.17.0",
24
+ "@babel/parser": "^7.17.0",
25
+ "@babel/plugin-transform-runtime": "^7.17.0",
26
26
  "@babel/preset-env": "^7.16.11",
27
27
  "babel-loader": "^8.2.3",
28
28
  "clean-css": "^5.2.4",
29
- "css-loader": "^6.5.1",
29
+ "css-loader": "^6.6.0",
30
30
  "fs-extra": "^10.0.0",
31
- "globby": "^13.1.0",
31
+ "globby": "^13.1.1",
32
32
  "html-minifier": "^4.0.0",
33
- "isomorphic-git": "^1.11.1",
33
+ "isomorphic-git": "^1.11.2",
34
34
  "json5-loader": "^4.0.1",
35
35
  "node-watch": "^0.7.3",
36
36
  "parse5": "^6.0.1",
37
37
  "raw-loader": "^4.0.2",
38
- "sass": "^1.49.0",
38
+ "sass": "^1.49.7",
39
39
  "sass-loader": "^12.4.0",
40
40
  "semver": "^7.3.5",
41
- "webpack": "^5.67.0",
42
- "webpack-dev-server": "^4.7.3"
41
+ "webpack": "^5.68.0",
42
+ "webpack-dev-server": "^4.7.4"
43
43
  }
44
44
  }
@@ -97,7 +97,7 @@ const nextAllSiblings = (el, selector) => {
97
97
  };
98
98
 
99
99
  export default class LWElement extends HTMLElement {
100
- me = self;
100
+ self = this;
101
101
  constructor(ast) {
102
102
  super();
103
103
  this.ast = ast;