@weapp-tailwindcss/cli 1.0.0 → 1.0.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/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const process = require('node:process');
3
4
  const commander = require('commander');
4
5
  const path = require('node:path');
5
6
  const fs = require('fs-extra');
@@ -19,6 +20,7 @@ const cosmiconfig = require('cosmiconfig');
19
20
 
20
21
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
21
22
 
23
+ const process__default = /*#__PURE__*/_interopDefaultCompat(process);
22
24
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
23
25
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
24
26
  const gulp__default = /*#__PURE__*/_interopDefaultCompat(gulp$1);
@@ -88,7 +90,7 @@ function createDefu(merger) {
88
90
  }
89
91
  const defu = createDefu();
90
92
 
91
- const version = "1.0.0";
93
+ const version = "1.0.2";
92
94
 
93
95
  const debug = createDebug__default("weapp-tw-cli");
94
96
 
@@ -518,9 +520,19 @@ function isTsLang(lang) {
518
520
  }
519
521
  async function getTasks(options) {
520
522
  let { typescriptOptions } = options;
521
- const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions, preprocessorOptions } = options;
523
+ const {
524
+ root: cwd,
525
+ weappTailwindcssOptions,
526
+ outDir,
527
+ src: srcBase,
528
+ extensions,
529
+ exclude,
530
+ include,
531
+ postcssOptions,
532
+ preprocessorOptions
533
+ } = options;
522
534
  const globsSet = new GlobsSet();
523
- const base = srcBase ? srcBase + "/" : "";
535
+ const base = srcBase ? `${srcBase}/` : "";
524
536
  const enableSass = Boolean(preprocessorOptions?.sass);
525
537
  const enableLess = Boolean(preprocessorOptions?.less);
526
538
  if (typescriptOptions === true) {
@@ -537,18 +549,18 @@ async function getTasks(options) {
537
549
  sass = createSass__default(sassLib);
538
550
  }
539
551
  const { transformJs, transformWxml, transformWxss } = gulp.createPlugins(weappTailwindcssOptions);
552
+ const outDirGlobs = [`!${outDir}/**/*`, `!./${outDir}/**/*`];
540
553
  function getGlobs(type) {
541
554
  const globs = [];
542
555
  if (typeof include === "function") {
543
556
  globs.push(...include(type).map((x) => x));
544
557
  }
545
558
  if (typeof exclude === "function") {
546
- globs.push(...exclude(type).map((x) => "!" + x));
559
+ globs.push(...exclude(type).map((x) => `!${x}`));
547
560
  } else if (Array.isArray(exclude)) {
548
- globs.push(...exclude.map((x) => "!" + x));
561
+ globs.push(...exclude.map((x) => `!${x}`));
549
562
  }
550
- globs.push(`!${outDir}/**/*`);
551
- globs.push(`!./${outDir}/**/*`);
563
+ globs.push(...outDirGlobs);
552
564
  return globs;
553
565
  }
554
566
  function getJsTasks() {
@@ -562,7 +574,10 @@ async function getTasks(options) {
562
574
  const loadTs = enableTs && isTs;
563
575
  let gulpTs;
564
576
  if (enableTs && typeof typescriptOptions !== "boolean") {
565
- gulpTs = typescript__default.createProject(typescriptOptions.tsConfigFileName ?? "tsconfig.json", typeof typescriptOptions === "boolean" ? {} : typescriptOptions);
577
+ gulpTs = typescript__default.createProject(
578
+ typescriptOptions.tsConfigFileName ?? "tsconfig.json",
579
+ typeof typescriptOptions === "boolean" ? {} : typescriptOptions
580
+ );
566
581
  }
567
582
  return function JsTask() {
568
583
  let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) });
@@ -630,7 +645,12 @@ async function getTasks(options) {
630
645
  );
631
646
  }
632
647
  return promisify(
633
- chain.pipe(gulpif__default(loadLess, less__default(typeof preprocessorOptions?.less === "boolean" ? void 0 : preprocessorOptions?.less))).pipe(gulpif__default(Boolean(postcssOptions), postcssrc__default(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
648
+ chain.pipe(
649
+ gulpif__default(
650
+ loadLess,
651
+ less__default(typeof preprocessorOptions?.less === "boolean" ? void 0 : preprocessorOptions?.less)
652
+ )
653
+ ).pipe(gulpif__default(Boolean(postcssOptions), postcssrc__default(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
634
654
  gulpif__default(
635
655
  loadSass || loadLess,
636
656
  rename__default({
@@ -671,7 +691,7 @@ async function getTasks(options) {
671
691
  });
672
692
  globsSet.add(globs);
673
693
  return promisify(
674
- gulp__default.src(globs, { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(
694
+ gulp__default.src([...globs, ...outDirGlobs], { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(
675
695
  gulp__default.dest(outDir, {
676
696
  cwd
677
697
  })
@@ -715,6 +735,7 @@ async function createBuilder(options) {
715
735
  clean: true,
716
736
  src: "",
717
737
  exclude: [...defaultNodeModulesDirs],
738
+ include: ["**/*.{png,jpg,jpeg,gif,svg,webp}"],
718
739
  extensions: {
719
740
  javascript: [...defaultJavascriptExtensions, ...defaultTypescriptExtensions, ...defaultWxsExtensions],
720
741
  html: ["wxml"],
@@ -755,7 +776,7 @@ async function createBuilder(options) {
755
776
  if (clean) {
756
777
  debug("del start");
757
778
  const { deleteAsync } = await import('del');
758
- const patterns = [outDir + "/**"];
779
+ const patterns = [`${outDir}/**`];
759
780
  await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
760
781
  debug("del end");
761
782
  }
@@ -766,7 +787,9 @@ async function createBuilder(options) {
766
787
  watch() {
767
788
  fs.ensureDirSync(path__default.resolve(cwd, outDir));
768
789
  const dumps = globsSet.dump();
769
- const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(Boolean);
790
+ const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(
791
+ Boolean
792
+ );
770
793
  watchOptions.ignored = [...globsSet.dumpIgnored(), ...arr];
771
794
  const watcher = gulp__default.watch(dumps, watchOptions, async (cb) => {
772
795
  try {
@@ -776,22 +799,24 @@ async function createBuilder(options) {
776
799
  cb(error);
777
800
  }
778
801
  });
779
- watcher.on("change", function(path2) {
802
+ watcher.on("change", (path2) => {
780
803
  console.log(`${pc__default.green("changed")} ${path2}`);
781
804
  });
782
- watcher.on("add", function(path2) {
805
+ watcher.on("add", (path2) => {
783
806
  console.log(`${pc__default.green("add")} ${path2}`);
784
807
  });
785
- watcher.on("unlink", function(path2) {
808
+ watcher.on("unlink", (path2) => {
786
809
  console.log(`${pc__default.green("remove")} ${path2}`);
787
810
  });
788
- watcher.on("ready", async function() {
811
+ watcher.on("ready", async () => {
789
812
  const meta = await localPkg.getPackageInfo("weapp-tailwindcss");
790
813
  let weappTwVersionStr = "";
791
814
  if (meta) {
792
815
  weappTwVersionStr = `(${pc__default.blue(pc__default.underline(meta.version))})`;
793
816
  }
794
- console.log(`${pc__default.bold(`${pc__default.green("weapp")}-${pc__default.blue("tailwindcss")}`)}${weappTwVersionStr} ${pc__default.cyan("cli")}(${pc__default.blue(pc__default.underline(version))}) is ready!`);
817
+ console.log(
818
+ `${pc__default.bold(`${pc__default.green("weapp")}-${pc__default.blue("tailwindcss")}`)}${weappTwVersionStr} ${pc__default.cyan("cli")}(${pc__default.blue(pc__default.underline(version))}) is ready!`
819
+ );
795
820
  });
796
821
  this.watcher = watcher;
797
822
  return this;
@@ -846,7 +871,9 @@ function updateProjectConfig(options) {
846
871
  set(projectConfig, "srcMiniprogramRoot", "dist/");
847
872
  set(projectConfig, "setting.packNpmManually", true);
848
873
  if (Array.isArray(get(projectConfig, "setting.packNpmRelationList"))) {
849
- const x = projectConfig.setting.packNpmRelationList.find((x2) => x2.packageJsonPath === "./package.json" && x2.miniprogramNpmDistDir === "./dist");
874
+ const x = projectConfig.setting.packNpmRelationList.find(
875
+ (x2) => x2.packageJsonPath === "./package.json" && x2.miniprogramNpmDistDir === "./dist"
876
+ );
850
877
  if (!x) {
851
878
  projectConfig.setting.packNpmRelationList.push({
852
879
  packageJsonPath: "./package.json",
@@ -890,7 +917,10 @@ function updatePackageJson(options) {
890
917
  }
891
918
  }
892
919
  function initConfig(options) {
893
- const { lang, root } = defu(options, { lang: "js", root: process.cwd() });
920
+ const { lang, root } = defu(options, {
921
+ lang: "js",
922
+ root: process__default.cwd()
923
+ });
894
924
  const configFilename = `weapp-tw.config.${lang ?? "js"}`;
895
925
  const configPath = path__default.resolve(root, configFilename);
896
926
  const tsconfigPath = path__default.resolve(root, "tsconfig.json");
@@ -926,7 +956,7 @@ module.exports = config
926
956
  }
927
957
 
928
958
  function createCli() {
929
- const cwd = process.cwd();
959
+ const cwd = process__default.cwd();
930
960
  const program = new commander.Command();
931
961
  const configLoader = createConfigLoader(cwd);
932
962
  const userDefinedConfig = configLoader.search(cwd);
package/dist/index.d.cts CHANGED
@@ -139,11 +139,11 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
139
139
  globsSet: GlobsSet;
140
140
  }>;
141
141
 
142
- type WeappTwCosmiconfigResult = {
142
+ interface WeappTwCosmiconfigResult {
143
143
  config: BuildOptions;
144
144
  filepath: string;
145
145
  isEmpty?: boolean;
146
- };
146
+ }
147
147
  declare function createConfigLoader(root: string): {
148
148
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
149
149
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
package/dist/index.d.mts CHANGED
@@ -139,11 +139,11 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
139
139
  globsSet: GlobsSet;
140
140
  }>;
141
141
 
142
- type WeappTwCosmiconfigResult = {
142
+ interface WeappTwCosmiconfigResult {
143
143
  config: BuildOptions;
144
144
  filepath: string;
145
145
  isEmpty?: boolean;
146
- };
146
+ }
147
147
  declare function createConfigLoader(root: string): {
148
148
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
149
149
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
package/dist/index.d.ts CHANGED
@@ -139,11 +139,11 @@ declare function watch(options?: Partial<BuildOptions>): Promise<{
139
139
  globsSet: GlobsSet;
140
140
  }>;
141
141
 
142
- type WeappTwCosmiconfigResult = {
142
+ interface WeappTwCosmiconfigResult {
143
143
  config: BuildOptions;
144
144
  filepath: string;
145
145
  isEmpty?: boolean;
146
- };
146
+ }
147
147
  declare function createConfigLoader(root: string): {
148
148
  search: (searchFrom?: string) => WeappTwCosmiconfigResult | undefined;
149
149
  load: (filepath: string) => cosmiconfig.CosmiconfigResult;
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import process from 'node:process';
1
2
  import { Command } from 'commander';
2
3
  import path from 'node:path';
3
4
  import fs, { ensureDirSync } from 'fs-extra';
@@ -71,7 +72,7 @@ function createDefu(merger) {
71
72
  }
72
73
  const defu = createDefu();
73
74
 
74
- const version = "1.0.0";
75
+ const version = "1.0.2";
75
76
 
76
77
  const debug = createDebug("weapp-tw-cli");
77
78
 
@@ -501,9 +502,19 @@ function isTsLang(lang) {
501
502
  }
502
503
  async function getTasks(options) {
503
504
  let { typescriptOptions } = options;
504
- const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions, preprocessorOptions } = options;
505
+ const {
506
+ root: cwd,
507
+ weappTailwindcssOptions,
508
+ outDir,
509
+ src: srcBase,
510
+ extensions,
511
+ exclude,
512
+ include,
513
+ postcssOptions,
514
+ preprocessorOptions
515
+ } = options;
505
516
  const globsSet = new GlobsSet();
506
- const base = srcBase ? srcBase + "/" : "";
517
+ const base = srcBase ? `${srcBase}/` : "";
507
518
  const enableSass = Boolean(preprocessorOptions?.sass);
508
519
  const enableLess = Boolean(preprocessorOptions?.less);
509
520
  if (typescriptOptions === true) {
@@ -520,18 +531,18 @@ async function getTasks(options) {
520
531
  sass = createSass(sassLib);
521
532
  }
522
533
  const { transformJs, transformWxml, transformWxss } = createPlugins(weappTailwindcssOptions);
534
+ const outDirGlobs = [`!${outDir}/**/*`, `!./${outDir}/**/*`];
523
535
  function getGlobs(type) {
524
536
  const globs = [];
525
537
  if (typeof include === "function") {
526
538
  globs.push(...include(type).map((x) => x));
527
539
  }
528
540
  if (typeof exclude === "function") {
529
- globs.push(...exclude(type).map((x) => "!" + x));
541
+ globs.push(...exclude(type).map((x) => `!${x}`));
530
542
  } else if (Array.isArray(exclude)) {
531
- globs.push(...exclude.map((x) => "!" + x));
543
+ globs.push(...exclude.map((x) => `!${x}`));
532
544
  }
533
- globs.push(`!${outDir}/**/*`);
534
- globs.push(`!./${outDir}/**/*`);
545
+ globs.push(...outDirGlobs);
535
546
  return globs;
536
547
  }
537
548
  function getJsTasks() {
@@ -545,7 +556,10 @@ async function getTasks(options) {
545
556
  const loadTs = enableTs && isTs;
546
557
  let gulpTs;
547
558
  if (enableTs && typeof typescriptOptions !== "boolean") {
548
- gulpTs = typescript.createProject(typescriptOptions.tsConfigFileName ?? "tsconfig.json", typeof typescriptOptions === "boolean" ? {} : typescriptOptions);
559
+ gulpTs = typescript.createProject(
560
+ typescriptOptions.tsConfigFileName ?? "tsconfig.json",
561
+ typeof typescriptOptions === "boolean" ? {} : typescriptOptions
562
+ );
549
563
  }
550
564
  return function JsTask() {
551
565
  let chain = gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsTask) });
@@ -613,7 +627,12 @@ async function getTasks(options) {
613
627
  );
614
628
  }
615
629
  return promisify(
616
- chain.pipe(gulpif(loadLess, less(typeof preprocessorOptions?.less === "boolean" ? void 0 : preprocessorOptions?.less))).pipe(gulpif(Boolean(postcssOptions), postcssrc(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
630
+ chain.pipe(
631
+ gulpif(
632
+ loadLess,
633
+ less(typeof preprocessorOptions?.less === "boolean" ? void 0 : preprocessorOptions?.less)
634
+ )
635
+ ).pipe(gulpif(Boolean(postcssOptions), postcssrc(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
617
636
  gulpif(
618
637
  loadSass || loadLess,
619
638
  rename({
@@ -654,7 +673,7 @@ async function getTasks(options) {
654
673
  });
655
674
  globsSet.add(globs);
656
675
  return promisify(
657
- gulp.src(globs, { cwd, since: gulp.lastRun(copyOthers) }).pipe(
676
+ gulp.src([...globs, ...outDirGlobs], { cwd, since: gulp.lastRun(copyOthers) }).pipe(
658
677
  gulp.dest(outDir, {
659
678
  cwd
660
679
  })
@@ -698,6 +717,7 @@ async function createBuilder(options) {
698
717
  clean: true,
699
718
  src: "",
700
719
  exclude: [...defaultNodeModulesDirs],
720
+ include: ["**/*.{png,jpg,jpeg,gif,svg,webp}"],
701
721
  extensions: {
702
722
  javascript: [...defaultJavascriptExtensions, ...defaultTypescriptExtensions, ...defaultWxsExtensions],
703
723
  html: ["wxml"],
@@ -738,7 +758,7 @@ async function createBuilder(options) {
738
758
  if (clean) {
739
759
  debug("del start");
740
760
  const { deleteAsync } = await import('del');
741
- const patterns = [outDir + "/**"];
761
+ const patterns = [`${outDir}/**`];
742
762
  await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
743
763
  debug("del end");
744
764
  }
@@ -749,7 +769,9 @@ async function createBuilder(options) {
749
769
  watch() {
750
770
  ensureDirSync(path.resolve(cwd, outDir));
751
771
  const dumps = globsSet.dump();
752
- const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(Boolean);
772
+ const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(
773
+ Boolean
774
+ );
753
775
  watchOptions.ignored = [...globsSet.dumpIgnored(), ...arr];
754
776
  const watcher = gulp.watch(dumps, watchOptions, async (cb) => {
755
777
  try {
@@ -759,22 +781,24 @@ async function createBuilder(options) {
759
781
  cb(error);
760
782
  }
761
783
  });
762
- watcher.on("change", function(path2) {
784
+ watcher.on("change", (path2) => {
763
785
  console.log(`${pc.green("changed")} ${path2}`);
764
786
  });
765
- watcher.on("add", function(path2) {
787
+ watcher.on("add", (path2) => {
766
788
  console.log(`${pc.green("add")} ${path2}`);
767
789
  });
768
- watcher.on("unlink", function(path2) {
790
+ watcher.on("unlink", (path2) => {
769
791
  console.log(`${pc.green("remove")} ${path2}`);
770
792
  });
771
- watcher.on("ready", async function() {
793
+ watcher.on("ready", async () => {
772
794
  const meta = await getPackageInfo("weapp-tailwindcss");
773
795
  let weappTwVersionStr = "";
774
796
  if (meta) {
775
797
  weappTwVersionStr = `(${pc.blue(pc.underline(meta.version))})`;
776
798
  }
777
- console.log(`${pc.bold(`${pc.green("weapp")}-${pc.blue("tailwindcss")}`)}${weappTwVersionStr} ${pc.cyan("cli")}(${pc.blue(pc.underline(version))}) is ready!`);
799
+ console.log(
800
+ `${pc.bold(`${pc.green("weapp")}-${pc.blue("tailwindcss")}`)}${weappTwVersionStr} ${pc.cyan("cli")}(${pc.blue(pc.underline(version))}) is ready!`
801
+ );
778
802
  });
779
803
  this.watcher = watcher;
780
804
  return this;
@@ -829,7 +853,9 @@ function updateProjectConfig(options) {
829
853
  set(projectConfig, "srcMiniprogramRoot", "dist/");
830
854
  set(projectConfig, "setting.packNpmManually", true);
831
855
  if (Array.isArray(get(projectConfig, "setting.packNpmRelationList"))) {
832
- const x = projectConfig.setting.packNpmRelationList.find((x2) => x2.packageJsonPath === "./package.json" && x2.miniprogramNpmDistDir === "./dist");
856
+ const x = projectConfig.setting.packNpmRelationList.find(
857
+ (x2) => x2.packageJsonPath === "./package.json" && x2.miniprogramNpmDistDir === "./dist"
858
+ );
833
859
  if (!x) {
834
860
  projectConfig.setting.packNpmRelationList.push({
835
861
  packageJsonPath: "./package.json",
@@ -873,7 +899,10 @@ function updatePackageJson(options) {
873
899
  }
874
900
  }
875
901
  function initConfig(options) {
876
- const { lang, root } = defu(options, { lang: "js", root: process.cwd() });
902
+ const { lang, root } = defu(options, {
903
+ lang: "js",
904
+ root: process.cwd()
905
+ });
877
906
  const configFilename = `weapp-tw.config.${lang ?? "js"}`;
878
907
  const configPath = path.resolve(root, configFilename);
879
908
  const tsconfigPath = path.resolve(root, "tsconfig.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "The cli of weapp-tailwindcss",
5
5
  "keywords": [
6
6
  "weapp",
@@ -47,13 +47,13 @@
47
47
  "local-pkg": "^0.5.0",
48
48
  "picocolors": "^1.0.0",
49
49
  "postcss": "^8.4.38",
50
- "postcss-load-config": "^5.0.3"
50
+ "postcss-load-config": "^5.1.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "less": "*",
54
54
  "sass": "*",
55
55
  "typescript": "*",
56
- "weapp-tailwindcss": "3.2.0"
56
+ "weapp-tailwindcss": "3.2.1"
57
57
  },
58
58
  "peerDependenciesMeta": {
59
59
  "less": {