@weapp-tailwindcss/cli 0.0.0-alpha.5 → 0.0.0-alpha.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 ice breaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -5,6 +5,8 @@ const path = require('node:path');
5
5
  const fs = require('fs-extra');
6
6
  const gulp$1 = require('gulp');
7
7
  const loadPostcssConfig = require('postcss-load-config');
8
+ const pc = require('picocolors');
9
+ const createDebug = require('debug');
8
10
  const gulp = require('weapp-tailwindcss/gulp');
9
11
  const postcssrc = require('gulp-postcss');
10
12
  const plumber = require('gulp-plumber');
@@ -17,6 +19,8 @@ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
17
19
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
18
20
  const gulp__default = /*#__PURE__*/_interopDefaultCompat(gulp$1);
19
21
  const loadPostcssConfig__default = /*#__PURE__*/_interopDefaultCompat(loadPostcssConfig);
22
+ const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
23
+ const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
20
24
  const postcssrc__default = /*#__PURE__*/_interopDefaultCompat(postcssrc);
21
25
  const plumber__default = /*#__PURE__*/_interopDefaultCompat(plumber);
22
26
  const gulpif__default = /*#__PURE__*/_interopDefaultCompat(gulpif);
@@ -77,6 +81,8 @@ function createDefu(merger) {
77
81
  }
78
82
  const defu = createDefu();
79
83
 
84
+ const debug = createDebug__default("weapp-tw-cli");
85
+
80
86
  var AssetType = /* @__PURE__ */ ((AssetType2) => {
81
87
  AssetType2["JavaScript"] = "javascript";
82
88
  AssetType2["Json"] = "json";
@@ -260,22 +266,36 @@ function createBuilder(options) {
260
266
  watchOptions,
261
267
  postcssOptions
262
268
  });
263
- const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
269
+ const tasks = {
270
+ css: getCssTasks(),
271
+ html: getHtmlTasks(),
272
+ json: getJsonTasks(),
273
+ js: getJsTasks(),
274
+ extra: [copyOthers]
275
+ };
264
276
  async function runTasks() {
265
- for (const task of tasks) {
266
- const s = task();
267
- if (s) {
268
- await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
277
+ debug("run tasks start");
278
+ for (const [key, value] of Object.entries(tasks)) {
279
+ debug(`run task ${pc__default.bold(pc__default.green(key))} start`);
280
+ for (const task of value) {
281
+ const s = task();
282
+ if (s) {
283
+ await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
284
+ }
269
285
  }
286
+ debug(`run task ${pc__default.bold(pc__default.green(key))} end`);
270
287
  }
288
+ debug("run tasks end");
271
289
  }
272
290
  return {
273
291
  watcher: void 0,
274
292
  async build() {
275
293
  if (clean) {
294
+ debug("del start");
276
295
  const { deleteAsync } = await import('del');
277
296
  const patterns = [outDir + "/**"];
278
297
  await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
298
+ debug("del end");
279
299
  }
280
300
  fs.ensureDirSync(path__default.resolve(cwd, outDir));
281
301
  await runTasks();
@@ -292,16 +312,16 @@ function createBuilder(options) {
292
312
  }
293
313
  });
294
314
  watcher.on("change", function(path2) {
295
- console.log(`File ${path2} was changed`);
315
+ console.log(`${pc__default.green("changed")} ${path2}`);
296
316
  });
297
317
  watcher.on("add", function(path2) {
298
- console.log(`File ${path2} was added`);
318
+ console.log(`${pc__default.green("add")} ${path2}`);
299
319
  });
300
320
  watcher.on("unlink", function(path2) {
301
- console.log(`File ${path2} was removed`);
321
+ console.log(`${pc__default.green("remove")} ${path2}`);
302
322
  });
303
323
  watcher.on("ready", function() {
304
- console.log(`Weapp-tailwindcss is Ready!`);
324
+ console.log(`${pc__default.green("weapp")}-${pc__default.blue("tailwindcss")} is ready!`);
305
325
  });
306
326
  this.watcher = watcher;
307
327
  return this;
@@ -697,7 +717,7 @@ function getDefaultConfig(root) {
697
717
  return {
698
718
  outDir: "dist",
699
719
  root,
700
- srcDir: "."
720
+ src: "."
701
721
  };
702
722
  }
703
723
  function defineConfig(options) {
@@ -760,13 +780,18 @@ function initConfig(options) {
760
780
  const { lang, root } = defu(options, { lang: "js", root: process.cwd() });
761
781
  const configFilename = `weapp-tw.config.${lang ?? "js"}`;
762
782
  const configPath = path__default.resolve(root, configFilename);
783
+ const tsconfigPath = path__default.resolve(root, "tsconfig.json");
784
+ const isTsconfigExisted = fs__default.existsSync(tsconfigPath);
763
785
  fs__default.ensureDirSync(root);
786
+ const configOptionsStr = isTsconfigExisted ? `{
787
+ src: './miniprogram'
788
+ }` : "{}";
764
789
  if (lang === "ts") {
765
790
  fs__default.writeFileSync(
766
791
  configPath,
767
792
  `import { defineConfig } from '@weapp-tailwindcss/cli'
768
793
 
769
- export default defineConfig({})
794
+ export default defineConfig(${configOptionsStr})
770
795
  `,
771
796
  "utf8"
772
797
  );
@@ -774,7 +799,7 @@ export default defineConfig({})
774
799
  fs__default.writeFileSync(
775
800
  configPath,
776
801
  `/** @type {import('@weapp-tailwindcss/cli').UserConfig} */
777
- module.exports = {}
802
+ module.exports = ${configOptionsStr}
778
803
  `,
779
804
  "utf8"
780
805
  );
package/dist/index.d.cts CHANGED
@@ -23,14 +23,15 @@ interface BuildOptions {
23
23
  exclude: string[] | ((type: AssetType) => string[]);
24
24
  include: string[] | ((type: AssetType) => string[]);
25
25
  extensions: {
26
- javascript: string[];
27
- html: string[];
28
- css: string[];
29
- json: string[];
26
+ javascript?: string[];
27
+ html?: string[];
28
+ css?: string[];
29
+ json?: string[];
30
30
  };
31
31
  postcssOptions?: Partial<Omit<Result, 'file'>>;
32
32
  watchOptions: WatchOptions;
33
33
  }
34
+ type UserConfig = Partial<BuildOptions>;
34
35
 
35
36
  declare function createBuilder(options?: Partial<BuildOptions>): {
36
37
  watcher: FSWatcher | undefined;
@@ -52,7 +53,7 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
52
53
  }>;
53
54
 
54
55
  type WeappTwCosmiconfigResult = {
55
- config: UserConfig;
56
+ config: BuildOptions;
56
57
  filepath: string;
57
58
  isEmpty?: boolean;
58
59
  };
@@ -60,13 +61,6 @@ declare function createConfigLoader(root: string): {
60
61
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
61
62
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
62
63
  };
63
- type UserConfig = {
64
- outDir?: string;
65
- root?: string;
66
- srcDir?: string;
67
- weappTailwindcssOptions?: UserDefinedOptions;
68
- clean?: boolean;
69
- };
70
- declare function defineConfig(options: UserConfig): UserConfig;
64
+ declare function defineConfig(options: Partial<BuildOptions>): Partial<BuildOptions>;
71
65
 
72
66
  export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
package/dist/index.d.mts CHANGED
@@ -23,14 +23,15 @@ interface BuildOptions {
23
23
  exclude: string[] | ((type: AssetType) => string[]);
24
24
  include: string[] | ((type: AssetType) => string[]);
25
25
  extensions: {
26
- javascript: string[];
27
- html: string[];
28
- css: string[];
29
- json: string[];
26
+ javascript?: string[];
27
+ html?: string[];
28
+ css?: string[];
29
+ json?: string[];
30
30
  };
31
31
  postcssOptions?: Partial<Omit<Result, 'file'>>;
32
32
  watchOptions: WatchOptions;
33
33
  }
34
+ type UserConfig = Partial<BuildOptions>;
34
35
 
35
36
  declare function createBuilder(options?: Partial<BuildOptions>): {
36
37
  watcher: FSWatcher | undefined;
@@ -52,7 +53,7 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
52
53
  }>;
53
54
 
54
55
  type WeappTwCosmiconfigResult = {
55
- config: UserConfig;
56
+ config: BuildOptions;
56
57
  filepath: string;
57
58
  isEmpty?: boolean;
58
59
  };
@@ -60,13 +61,6 @@ declare function createConfigLoader(root: string): {
60
61
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
61
62
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
62
63
  };
63
- type UserConfig = {
64
- outDir?: string;
65
- root?: string;
66
- srcDir?: string;
67
- weappTailwindcssOptions?: UserDefinedOptions;
68
- clean?: boolean;
69
- };
70
- declare function defineConfig(options: UserConfig): UserConfig;
64
+ declare function defineConfig(options: Partial<BuildOptions>): Partial<BuildOptions>;
71
65
 
72
66
  export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
package/dist/index.d.ts CHANGED
@@ -23,14 +23,15 @@ interface BuildOptions {
23
23
  exclude: string[] | ((type: AssetType) => string[]);
24
24
  include: string[] | ((type: AssetType) => string[]);
25
25
  extensions: {
26
- javascript: string[];
27
- html: string[];
28
- css: string[];
29
- json: string[];
26
+ javascript?: string[];
27
+ html?: string[];
28
+ css?: string[];
29
+ json?: string[];
30
30
  };
31
31
  postcssOptions?: Partial<Omit<Result, 'file'>>;
32
32
  watchOptions: WatchOptions;
33
33
  }
34
+ type UserConfig = Partial<BuildOptions>;
34
35
 
35
36
  declare function createBuilder(options?: Partial<BuildOptions>): {
36
37
  watcher: FSWatcher | undefined;
@@ -52,7 +53,7 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
52
53
  }>;
53
54
 
54
55
  type WeappTwCosmiconfigResult = {
55
- config: UserConfig;
56
+ config: BuildOptions;
56
57
  filepath: string;
57
58
  isEmpty?: boolean;
58
59
  };
@@ -60,13 +61,6 @@ declare function createConfigLoader(root: string): {
60
61
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
61
62
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
62
63
  };
63
- type UserConfig = {
64
- outDir?: string;
65
- root?: string;
66
- srcDir?: string;
67
- weappTailwindcssOptions?: UserDefinedOptions;
68
- clean?: boolean;
69
- };
70
- declare function defineConfig(options: UserConfig): UserConfig;
64
+ declare function defineConfig(options: Partial<BuildOptions>): Partial<BuildOptions>;
71
65
 
72
66
  export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
package/dist/index.mjs CHANGED
@@ -3,6 +3,8 @@ import path from 'node:path';
3
3
  import fs, { ensureDirSync } from 'fs-extra';
4
4
  import gulp from 'gulp';
5
5
  import loadPostcssConfig from 'postcss-load-config';
6
+ import pc from 'picocolors';
7
+ import createDebug from 'debug';
6
8
  import { createPlugins } from 'weapp-tailwindcss/gulp';
7
9
  import postcssrc from 'gulp-postcss';
8
10
  import plumber from 'gulp-plumber';
@@ -65,6 +67,8 @@ function createDefu(merger) {
65
67
  }
66
68
  const defu = createDefu();
67
69
 
70
+ const debug = createDebug("weapp-tw-cli");
71
+
68
72
  var AssetType = /* @__PURE__ */ ((AssetType2) => {
69
73
  AssetType2["JavaScript"] = "javascript";
70
74
  AssetType2["Json"] = "json";
@@ -248,22 +252,36 @@ function createBuilder(options) {
248
252
  watchOptions,
249
253
  postcssOptions
250
254
  });
251
- const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
255
+ const tasks = {
256
+ css: getCssTasks(),
257
+ html: getHtmlTasks(),
258
+ json: getJsonTasks(),
259
+ js: getJsTasks(),
260
+ extra: [copyOthers]
261
+ };
252
262
  async function runTasks() {
253
- for (const task of tasks) {
254
- const s = task();
255
- if (s) {
256
- await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
263
+ debug("run tasks start");
264
+ for (const [key, value] of Object.entries(tasks)) {
265
+ debug(`run task ${pc.bold(pc.green(key))} start`);
266
+ for (const task of value) {
267
+ const s = task();
268
+ if (s) {
269
+ await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
270
+ }
257
271
  }
272
+ debug(`run task ${pc.bold(pc.green(key))} end`);
258
273
  }
274
+ debug("run tasks end");
259
275
  }
260
276
  return {
261
277
  watcher: void 0,
262
278
  async build() {
263
279
  if (clean) {
280
+ debug("del start");
264
281
  const { deleteAsync } = await import('del');
265
282
  const patterns = [outDir + "/**"];
266
283
  await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
284
+ debug("del end");
267
285
  }
268
286
  ensureDirSync(path.resolve(cwd, outDir));
269
287
  await runTasks();
@@ -280,16 +298,16 @@ function createBuilder(options) {
280
298
  }
281
299
  });
282
300
  watcher.on("change", function(path2) {
283
- console.log(`File ${path2} was changed`);
301
+ console.log(`${pc.green("changed")} ${path2}`);
284
302
  });
285
303
  watcher.on("add", function(path2) {
286
- console.log(`File ${path2} was added`);
304
+ console.log(`${pc.green("add")} ${path2}`);
287
305
  });
288
306
  watcher.on("unlink", function(path2) {
289
- console.log(`File ${path2} was removed`);
307
+ console.log(`${pc.green("remove")} ${path2}`);
290
308
  });
291
309
  watcher.on("ready", function() {
292
- console.log(`Weapp-tailwindcss is Ready!`);
310
+ console.log(`${pc.green("weapp")}-${pc.blue("tailwindcss")} is ready!`);
293
311
  });
294
312
  this.watcher = watcher;
295
313
  return this;
@@ -685,7 +703,7 @@ function getDefaultConfig(root) {
685
703
  return {
686
704
  outDir: "dist",
687
705
  root,
688
- srcDir: "."
706
+ src: "."
689
707
  };
690
708
  }
691
709
  function defineConfig(options) {
@@ -748,13 +766,18 @@ function initConfig(options) {
748
766
  const { lang, root } = defu(options, { lang: "js", root: process.cwd() });
749
767
  const configFilename = `weapp-tw.config.${lang ?? "js"}`;
750
768
  const configPath = path.resolve(root, configFilename);
769
+ const tsconfigPath = path.resolve(root, "tsconfig.json");
770
+ const isTsconfigExisted = fs.existsSync(tsconfigPath);
751
771
  fs.ensureDirSync(root);
772
+ const configOptionsStr = isTsconfigExisted ? `{
773
+ src: './miniprogram'
774
+ }` : "{}";
752
775
  if (lang === "ts") {
753
776
  fs.writeFileSync(
754
777
  configPath,
755
778
  `import { defineConfig } from '@weapp-tailwindcss/cli'
756
779
 
757
- export default defineConfig({})
780
+ export default defineConfig(${configOptionsStr})
758
781
  `,
759
782
  "utf8"
760
783
  );
@@ -762,7 +785,7 @@ export default defineConfig({})
762
785
  fs.writeFileSync(
763
786
  configPath,
764
787
  `/** @type {import('@weapp-tailwindcss/cli').UserConfig} */
765
- module.exports = {}
788
+ module.exports = ${configOptionsStr}
766
789
  `,
767
790
  "utf8"
768
791
  );
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/cli",
3
- "version": "0.0.0-alpha.5",
3
+ "version": "0.0.0-alpha.6",
4
4
  "description": "The cli of weapp-tailwindcss",
5
- "keywords": [],
6
- "author": "",
7
- "license": "ISC",
5
+ "keywords": [
6
+ "weapp",
7
+ "tailwindcss",
8
+ "cli",
9
+ "plugin"
10
+ ],
11
+ "author": "SonOfMagic <qq1324318532@gmail.com>",
12
+ "license": "MIT",
13
+ "bugs": {
14
+ "url": "https://github.com/sonofmagic/weapp-tailwindcss-webpack-plugin/issues"
15
+ },
16
+ "homepage": "https://weapp-tw.icebreaker.top",
8
17
  "sideEffects": false,
9
18
  "type": "commonjs",
10
19
  "exports": {
@@ -23,19 +32,24 @@
23
32
  "dependencies": {
24
33
  "commander": "^12.0.0",
25
34
  "cosmiconfig": "^9.0.0",
35
+ "debug": "4.3.4",
26
36
  "del": "^7.1.0",
27
37
  "fs-extra": "^11.2.0",
28
38
  "gulp": "^5.0.0",
39
+ "gulp-if": "^3.0.0",
29
40
  "gulp-less": "^5.0.0",
30
41
  "gulp-plumber": "^1.2.1",
31
42
  "gulp-postcss": "^10.0.0",
32
43
  "gulp-sass": "^5.1.0",
33
- "gulp-if": "^3.0.0",
44
+ "picocolors": "^1.0.0",
34
45
  "postcss": "^8.4.38",
35
- "postcss-load-config": "^5.0.3",
36
- "weapp-tailwindcss": "3.2.0-alpha.4"
46
+ "postcss-load-config": "^5.0.3"
47
+ },
48
+ "peerDependencies": {
49
+ "weapp-tailwindcss": "3.2.0-alpha.7"
37
50
  },
38
51
  "devDependencies": {
52
+ "@types/debug": "^4.1.12",
39
53
  "@types/fs-extra": "^11.0.4",
40
54
  "@types/get-value": "^3.0.5",
41
55
  "@types/gulp": "^4.0.17",