@weapp-tailwindcss/cli 0.0.0-alpha.7 → 0.0.0-alpha.9
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 +1 -14
- package/dist/index.cjs +136 -70
- package/dist/index.d.cts +68 -3
- package/dist/index.d.mts +68 -3
- package/dist/index.d.ts +68 -3
- package/dist/index.mjs +136 -69
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
# @weapp-tailwindcss/cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
{
|
|
5
|
-
"setting": {
|
|
6
|
-
"packNpmManually": true,
|
|
7
|
-
"packNpmRelationList": [
|
|
8
|
-
{
|
|
9
|
-
"packageJsonPath": "./package.json",
|
|
10
|
-
"miniprogramNpmDistDir": "./dist"
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
"miniprogramRoot": "dist/"
|
|
15
|
-
}
|
|
16
|
-
```
|
|
3
|
+
<https://weapp-tw.icebreaker.top/docs/quick-start/native/install>
|
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,10 @@ const fs = require('fs-extra');
|
|
|
6
6
|
const gulp$1 = require('gulp');
|
|
7
7
|
const loadPostcssConfig = require('postcss-load-config');
|
|
8
8
|
const pc = require('picocolors');
|
|
9
|
+
const localPkg = require('local-pkg');
|
|
9
10
|
const createDebug = require('debug');
|
|
10
11
|
const gulp = require('weapp-tailwindcss/gulp');
|
|
11
12
|
const postcssrc = require('gulp-postcss');
|
|
12
|
-
const plumber = require('gulp-plumber');
|
|
13
13
|
const gulpif = require('gulp-if');
|
|
14
14
|
const createSass = require('gulp-sass');
|
|
15
15
|
const rename = require('gulp-rename');
|
|
@@ -26,7 +26,6 @@ const loadPostcssConfig__default = /*#__PURE__*/_interopDefaultCompat(loadPostcs
|
|
|
26
26
|
const pc__default = /*#__PURE__*/_interopDefaultCompat(pc);
|
|
27
27
|
const createDebug__default = /*#__PURE__*/_interopDefaultCompat(createDebug);
|
|
28
28
|
const postcssrc__default = /*#__PURE__*/_interopDefaultCompat(postcssrc);
|
|
29
|
-
const plumber__default = /*#__PURE__*/_interopDefaultCompat(plumber);
|
|
30
29
|
const gulpif__default = /*#__PURE__*/_interopDefaultCompat(gulpif);
|
|
31
30
|
const createSass__default = /*#__PURE__*/_interopDefaultCompat(createSass);
|
|
32
31
|
const rename__default = /*#__PURE__*/_interopDefaultCompat(rename);
|
|
@@ -89,8 +88,48 @@ function createDefu(merger) {
|
|
|
89
88
|
}
|
|
90
89
|
const defu = createDefu();
|
|
91
90
|
|
|
91
|
+
const version = "0.0.0-alpha.9";
|
|
92
|
+
|
|
92
93
|
const debug = createDebug__default("weapp-tw-cli");
|
|
93
94
|
|
|
95
|
+
var __defProp = Object.defineProperty;
|
|
96
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
97
|
+
var __publicField = (obj, key, value) => {
|
|
98
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
99
|
+
return value;
|
|
100
|
+
};
|
|
101
|
+
class GlobsSet {
|
|
102
|
+
constructor() {
|
|
103
|
+
__publicField(this, "includeSet");
|
|
104
|
+
__publicField(this, "excludeSet");
|
|
105
|
+
this.includeSet = /* @__PURE__ */ new Set();
|
|
106
|
+
this.excludeSet = /* @__PURE__ */ new Set();
|
|
107
|
+
}
|
|
108
|
+
isExcludeGlob(value) {
|
|
109
|
+
return value[0] === "!";
|
|
110
|
+
}
|
|
111
|
+
addSingle(value) {
|
|
112
|
+
return this.isExcludeGlob(value) ? this.excludeSet.add(value) : this.includeSet.add(value);
|
|
113
|
+
}
|
|
114
|
+
add(...value) {
|
|
115
|
+
for (const v of value) {
|
|
116
|
+
if (Array.isArray(v)) {
|
|
117
|
+
for (const vv of v) {
|
|
118
|
+
this.addSingle(vv);
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
this.addSingle(v);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
dump() {
|
|
126
|
+
return [...this.includeSet, ...this.excludeSet];
|
|
127
|
+
}
|
|
128
|
+
dumpIgnored() {
|
|
129
|
+
return [...this.excludeSet].map((x) => x.slice(1));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
94
133
|
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
95
134
|
AssetType2["JavaScript"] = "javascript";
|
|
96
135
|
AssetType2["Json"] = "json";
|
|
@@ -450,6 +489,23 @@ const get = /*@__PURE__*/getDefaultExportFromCjs(getValue);
|
|
|
450
489
|
function isObject(x) {
|
|
451
490
|
return typeof x === "object" && x !== null;
|
|
452
491
|
}
|
|
492
|
+
function promisify(task) {
|
|
493
|
+
return new Promise((resolve, reject) => {
|
|
494
|
+
if (Array.isArray(task)) {
|
|
495
|
+
return Promise.all(task.map((x) => promisify(x))).then(resolve).catch(reject);
|
|
496
|
+
} else {
|
|
497
|
+
if (task.destroyed) {
|
|
498
|
+
resolve(void 0);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
task.on("finish", () => {
|
|
502
|
+
resolve(void 0);
|
|
503
|
+
}).on("error", (err) => {
|
|
504
|
+
reject(err);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
453
509
|
|
|
454
510
|
function isSassLang(lang) {
|
|
455
511
|
return lang === "scss" || lang === "sass";
|
|
@@ -463,7 +519,7 @@ function isTsLang(lang) {
|
|
|
463
519
|
async function getTasks(options) {
|
|
464
520
|
let { typescriptOptions } = options;
|
|
465
521
|
const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions, preprocessorOptions } = options;
|
|
466
|
-
const globsSet =
|
|
522
|
+
const globsSet = new GlobsSet();
|
|
467
523
|
const base = srcBase ? srcBase + "/" : "";
|
|
468
524
|
const enableSass = Boolean(preprocessorOptions?.sass);
|
|
469
525
|
const enableLess = Boolean(preprocessorOptions?.less);
|
|
@@ -481,17 +537,6 @@ async function getTasks(options) {
|
|
|
481
537
|
sass = createSass__default(sassLib);
|
|
482
538
|
}
|
|
483
539
|
const { transformJs, transformWxml, transformWxss } = gulp.createPlugins(weappTailwindcssOptions);
|
|
484
|
-
function globsSetAdd(...value) {
|
|
485
|
-
for (const v of value) {
|
|
486
|
-
if (Array.isArray(v)) {
|
|
487
|
-
for (const vv of v) {
|
|
488
|
-
globsSet.add(vv);
|
|
489
|
-
}
|
|
490
|
-
} else {
|
|
491
|
-
globsSet.add(v);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
540
|
function getGlobs(type) {
|
|
496
541
|
const globs = [];
|
|
497
542
|
if (typeof include === "function") {
|
|
@@ -503,15 +548,16 @@ async function getTasks(options) {
|
|
|
503
548
|
globs.push(...exclude.map((x) => "!" + x));
|
|
504
549
|
}
|
|
505
550
|
globs.push(`!${outDir}/**/*`);
|
|
551
|
+
globs.push(`!./${outDir}/**/*`);
|
|
506
552
|
return globs;
|
|
507
553
|
}
|
|
508
554
|
function getJsTasks() {
|
|
509
555
|
const assetType = AssetType.JavaScript;
|
|
510
556
|
const globs = getGlobs(assetType);
|
|
511
|
-
|
|
557
|
+
globsSet.add(globs);
|
|
512
558
|
return extensions[assetType]?.map((x) => {
|
|
513
559
|
const src = `${base}**/*.${x}`;
|
|
514
|
-
|
|
560
|
+
globsSet.add(src);
|
|
515
561
|
const isTs = isTsLang(x);
|
|
516
562
|
const loadTs = enableTs && isTs;
|
|
517
563
|
let gulpTs;
|
|
@@ -519,27 +565,29 @@ async function getTasks(options) {
|
|
|
519
565
|
gulpTs = typescript__default.createProject(typescriptOptions.tsConfigFileName ?? "tsconfig.json", typeof typescriptOptions === "boolean" ? {} : typescriptOptions);
|
|
520
566
|
}
|
|
521
567
|
return function JsTask() {
|
|
522
|
-
let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) })
|
|
568
|
+
let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) });
|
|
523
569
|
if (loadTs) {
|
|
524
570
|
chain = chain.pipe(gulpTs());
|
|
525
571
|
}
|
|
526
|
-
return
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
572
|
+
return promisify(
|
|
573
|
+
chain.pipe(
|
|
574
|
+
transformJs({
|
|
575
|
+
babelParserOptions: !enableTs && isTs ? {
|
|
576
|
+
plugins: ["typescript"]
|
|
577
|
+
} : void 0
|
|
578
|
+
})
|
|
579
|
+
).pipe(
|
|
580
|
+
gulpif__default(
|
|
581
|
+
loadTs,
|
|
582
|
+
rename__default({
|
|
583
|
+
extname: ".js"
|
|
584
|
+
})
|
|
585
|
+
)
|
|
586
|
+
).pipe(
|
|
587
|
+
gulp__default.dest(outDir, {
|
|
588
|
+
cwd
|
|
537
589
|
})
|
|
538
590
|
)
|
|
539
|
-
).pipe(
|
|
540
|
-
gulp__default.dest(outDir, {
|
|
541
|
-
cwd
|
|
542
|
-
})
|
|
543
591
|
);
|
|
544
592
|
};
|
|
545
593
|
});
|
|
@@ -547,15 +595,17 @@ async function getTasks(options) {
|
|
|
547
595
|
function getJsonTasks() {
|
|
548
596
|
const assetType = AssetType.Json;
|
|
549
597
|
const globs = getGlobs(assetType);
|
|
550
|
-
|
|
598
|
+
globsSet.add(globs);
|
|
551
599
|
return extensions[assetType]?.map((x) => {
|
|
552
600
|
const src = `${base}**/*.${x}`;
|
|
553
|
-
|
|
601
|
+
globsSet.add(src);
|
|
554
602
|
return function JsonTask() {
|
|
555
|
-
return
|
|
556
|
-
gulp__default.
|
|
557
|
-
|
|
558
|
-
|
|
603
|
+
return promisify(
|
|
604
|
+
gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsonTask) }).pipe(
|
|
605
|
+
gulp__default.dest(outDir, {
|
|
606
|
+
cwd
|
|
607
|
+
})
|
|
608
|
+
)
|
|
559
609
|
);
|
|
560
610
|
};
|
|
561
611
|
});
|
|
@@ -563,14 +613,14 @@ async function getTasks(options) {
|
|
|
563
613
|
function getCssTasks() {
|
|
564
614
|
const assetType = AssetType.Css;
|
|
565
615
|
const globs = getGlobs(assetType);
|
|
566
|
-
|
|
616
|
+
globsSet.add(globs);
|
|
567
617
|
return extensions[assetType]?.map((x) => {
|
|
568
618
|
const src = `${base}**/*.${x}`;
|
|
569
|
-
|
|
619
|
+
globsSet.add(src);
|
|
570
620
|
const loadSass = enableSass && isSassLang(x);
|
|
571
621
|
const loadLess = enableLess && isLessLang(x);
|
|
572
622
|
return function CssTask() {
|
|
573
|
-
let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(CssTask) })
|
|
623
|
+
let chain = gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(CssTask) });
|
|
574
624
|
if (loadSass) {
|
|
575
625
|
chain = chain.pipe(
|
|
576
626
|
sass.sync(
|
|
@@ -579,17 +629,19 @@ async function getTasks(options) {
|
|
|
579
629
|
).on("error", sass.logError)
|
|
580
630
|
);
|
|
581
631
|
}
|
|
582
|
-
return
|
|
583
|
-
gulpif__default(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
632
|
+
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(
|
|
634
|
+
gulpif__default(
|
|
635
|
+
loadSass || loadLess,
|
|
636
|
+
rename__default({
|
|
637
|
+
extname: ".wxss"
|
|
638
|
+
})
|
|
639
|
+
)
|
|
640
|
+
).pipe(
|
|
641
|
+
gulp__default.dest(outDir, {
|
|
642
|
+
cwd
|
|
587
643
|
})
|
|
588
644
|
)
|
|
589
|
-
).pipe(
|
|
590
|
-
gulp__default.dest(outDir, {
|
|
591
|
-
cwd
|
|
592
|
-
})
|
|
593
645
|
);
|
|
594
646
|
};
|
|
595
647
|
});
|
|
@@ -597,15 +649,17 @@ async function getTasks(options) {
|
|
|
597
649
|
function getHtmlTasks() {
|
|
598
650
|
const assetType = AssetType.Html;
|
|
599
651
|
const globs = getGlobs(assetType);
|
|
600
|
-
|
|
652
|
+
globsSet.add(globs);
|
|
601
653
|
return extensions[assetType]?.map((x) => {
|
|
602
654
|
const src = `${base}**/*.${x}`;
|
|
603
|
-
|
|
655
|
+
globsSet.add(src);
|
|
604
656
|
return function HtmlTask() {
|
|
605
|
-
return
|
|
606
|
-
gulp__default.
|
|
607
|
-
|
|
608
|
-
|
|
657
|
+
return promisify(
|
|
658
|
+
gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(HtmlTask) }).pipe(transformWxml()).pipe(
|
|
659
|
+
gulp__default.dest(outDir, {
|
|
660
|
+
cwd
|
|
661
|
+
})
|
|
662
|
+
)
|
|
609
663
|
);
|
|
610
664
|
};
|
|
611
665
|
});
|
|
@@ -615,11 +669,13 @@ async function getTasks(options) {
|
|
|
615
669
|
const globs = include.map((x) => {
|
|
616
670
|
return `${base}${x}`;
|
|
617
671
|
});
|
|
618
|
-
|
|
619
|
-
return
|
|
620
|
-
gulp__default.
|
|
621
|
-
|
|
622
|
-
|
|
672
|
+
globsSet.add(globs);
|
|
673
|
+
return promisify(
|
|
674
|
+
gulp__default.src(globs, { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(
|
|
675
|
+
gulp__default.dest(outDir, {
|
|
676
|
+
cwd
|
|
677
|
+
})
|
|
678
|
+
)
|
|
623
679
|
);
|
|
624
680
|
}
|
|
625
681
|
}
|
|
@@ -644,7 +700,8 @@ const defaultNodeModulesDirs = [
|
|
|
644
700
|
"**/project.private.config.json/**",
|
|
645
701
|
"**/package.json/**",
|
|
646
702
|
"postcss.config.js",
|
|
647
|
-
"tailwind.config.js"
|
|
703
|
+
"tailwind.config.js",
|
|
704
|
+
"weapp-tw.config.js"
|
|
648
705
|
];
|
|
649
706
|
async function createBuilder(options) {
|
|
650
707
|
let postcssOptionsFromConfig;
|
|
@@ -665,6 +722,7 @@ async function createBuilder(options) {
|
|
|
665
722
|
json: ["json"]
|
|
666
723
|
},
|
|
667
724
|
watchOptions: {
|
|
725
|
+
cwd: options?.root,
|
|
668
726
|
events: ["add", "change", "unlink", "ready"]
|
|
669
727
|
},
|
|
670
728
|
postcssOptions: postcssOptionsFromConfig
|
|
@@ -683,10 +741,7 @@ async function createBuilder(options) {
|
|
|
683
741
|
if (value) {
|
|
684
742
|
debug(`run task ${pc__default.bold(pc__default.green(key))} start`);
|
|
685
743
|
for (const task of value) {
|
|
686
|
-
|
|
687
|
-
if (s) {
|
|
688
|
-
await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
|
|
689
|
-
}
|
|
744
|
+
await task();
|
|
690
745
|
}
|
|
691
746
|
debug(`run task ${pc__default.bold(pc__default.green(key))} end`);
|
|
692
747
|
}
|
|
@@ -710,7 +765,10 @@ async function createBuilder(options) {
|
|
|
710
765
|
},
|
|
711
766
|
watch() {
|
|
712
767
|
fs.ensureDirSync(path__default.resolve(cwd, outDir));
|
|
713
|
-
const
|
|
768
|
+
const dumps = globsSet.dump();
|
|
769
|
+
const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(Boolean);
|
|
770
|
+
watchOptions.ignored = [...globsSet.dumpIgnored(), ...arr];
|
|
771
|
+
const watcher = gulp__default.watch(dumps, watchOptions, async (cb) => {
|
|
714
772
|
try {
|
|
715
773
|
await runTasks();
|
|
716
774
|
cb();
|
|
@@ -727,8 +785,13 @@ async function createBuilder(options) {
|
|
|
727
785
|
watcher.on("unlink", function(path2) {
|
|
728
786
|
console.log(`${pc__default.green("remove")} ${path2}`);
|
|
729
787
|
});
|
|
730
|
-
watcher.on("ready", function() {
|
|
731
|
-
|
|
788
|
+
watcher.on("ready", async function() {
|
|
789
|
+
const meta = await localPkg.getPackageInfo("weapp-tailwindcss");
|
|
790
|
+
let weappTwVersionStr = "";
|
|
791
|
+
if (meta) {
|
|
792
|
+
weappTwVersionStr = `(${pc__default.blue(pc__default.underline(meta.version))})`;
|
|
793
|
+
}
|
|
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!`);
|
|
732
795
|
});
|
|
733
796
|
this.watcher = watcher;
|
|
734
797
|
return this;
|
|
@@ -818,6 +881,7 @@ function updatePackageJson(options) {
|
|
|
818
881
|
const packageJson = fs__default.readJSONSync(packageJsonPath);
|
|
819
882
|
set(packageJson, "scripts.dev", "weapp-tw dev");
|
|
820
883
|
set(packageJson, "scripts.build", "weapp-tw build");
|
|
884
|
+
set(packageJson, "scripts.postinstall", "weapp-tw patch");
|
|
821
885
|
fs__default.outputJSONSync(dest ?? packageJsonPath, packageJson, {
|
|
822
886
|
spaces: 2
|
|
823
887
|
});
|
|
@@ -848,7 +912,9 @@ export default defineConfig(${configOptionsStr})
|
|
|
848
912
|
fs__default.writeFileSync(
|
|
849
913
|
configPath,
|
|
850
914
|
`/** @type {import('@weapp-tailwindcss/cli').UserConfig} */
|
|
851
|
-
|
|
915
|
+
const config = ${configOptionsStr}
|
|
916
|
+
|
|
917
|
+
module.exports = config
|
|
852
918
|
`,
|
|
853
919
|
"utf8"
|
|
854
920
|
);
|
package/dist/index.d.cts
CHANGED
|
@@ -9,6 +9,17 @@ import * as cosmiconfig from 'cosmiconfig';
|
|
|
9
9
|
|
|
10
10
|
declare function createCli(): Command;
|
|
11
11
|
|
|
12
|
+
declare class GlobsSet {
|
|
13
|
+
includeSet: Set<string>;
|
|
14
|
+
excludeSet: Set<string>;
|
|
15
|
+
constructor();
|
|
16
|
+
isExcludeGlob(value: string): boolean;
|
|
17
|
+
addSingle(value: string): Set<string>;
|
|
18
|
+
add(...value: string[] | string[][]): void;
|
|
19
|
+
dump(): string[];
|
|
20
|
+
dumpIgnored(): string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
declare enum AssetType {
|
|
13
24
|
JavaScript = "javascript",
|
|
14
25
|
Json = "json",
|
|
@@ -29,25 +40,79 @@ interface GulpSassOptions extends Options<'sync'> {
|
|
|
29
40
|
sync?: boolean | undefined;
|
|
30
41
|
}
|
|
31
42
|
interface BuildOptions {
|
|
43
|
+
/**
|
|
44
|
+
* @group 0.重要配置
|
|
45
|
+
* @description 传递给 `weapp-tailwindcss` 的选项, [参考配置](/docs/api/interfaces/UserDefinedOptions)
|
|
46
|
+
*/
|
|
32
47
|
weappTailwindcssOptions: UserDefinedOptions;
|
|
48
|
+
/**
|
|
49
|
+
* @group 1.打包配置
|
|
50
|
+
* @default `dist`
|
|
51
|
+
* @description 输出目录
|
|
52
|
+
*/
|
|
33
53
|
outDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* @group 1.打包配置
|
|
56
|
+
* @default `process.cwd()`
|
|
57
|
+
* @description 根目录
|
|
58
|
+
*/
|
|
34
59
|
root: string;
|
|
60
|
+
/**
|
|
61
|
+
* @group 3.一般配置
|
|
62
|
+
* @default `true`
|
|
63
|
+
* @description build 的时候是否清除
|
|
64
|
+
*/
|
|
35
65
|
clean: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @group 1.打包配置
|
|
68
|
+
* @default `.`
|
|
69
|
+
* @description src 目录,相对路径,通常用于原生 typescript 项目
|
|
70
|
+
*/
|
|
36
71
|
src: string;
|
|
72
|
+
/**
|
|
73
|
+
* @group 1.打包配置
|
|
74
|
+
* @description 排除的文件目录
|
|
75
|
+
*/
|
|
37
76
|
exclude: string[] | ((type: AssetType) => string[]);
|
|
77
|
+
/**
|
|
78
|
+
* @group 1.打包配置
|
|
79
|
+
* @description 包括的文件目录
|
|
80
|
+
*/
|
|
38
81
|
include: string[] | ((type: AssetType) => string[]);
|
|
82
|
+
/**
|
|
83
|
+
* @group 1.打包配置
|
|
84
|
+
* @description 包括的文件后缀分类
|
|
85
|
+
*/
|
|
39
86
|
extensions: {
|
|
40
87
|
javascript?: string[];
|
|
41
88
|
html?: string[];
|
|
42
89
|
css?: string[];
|
|
43
90
|
json?: string[];
|
|
44
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* @group 1.打包配置
|
|
94
|
+
* @description postcss 配置,默认会去请求 `root` 下的 `postcss.config.js`
|
|
95
|
+
*/
|
|
45
96
|
postcssOptions?: Partial<Omit<Result, 'file'>>;
|
|
97
|
+
/**
|
|
98
|
+
* @group 2.编译支持
|
|
99
|
+
* @description 预处理配置,支持 sass 和 less,需要传入来开启编译
|
|
100
|
+
* @description 启用 sass 需要安装 sass, less 同样
|
|
101
|
+
*/
|
|
46
102
|
preprocessorOptions?: {
|
|
47
103
|
sass?: boolean | GulpSassOptions;
|
|
48
104
|
less?: boolean | GulpLessOptions;
|
|
49
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* @group 1.打包配置
|
|
108
|
+
* @description weapp-tw dev 的 watch 配置
|
|
109
|
+
*/
|
|
50
110
|
watchOptions: WatchOptions;
|
|
111
|
+
/**
|
|
112
|
+
* @group 2.编译支持
|
|
113
|
+
* @description typescript 的编译配置,默认不传伟不编译 ts
|
|
114
|
+
* @description 需要安装 typescript
|
|
115
|
+
*/
|
|
51
116
|
typescriptOptions: boolean | {
|
|
52
117
|
settings?: Settings;
|
|
53
118
|
tsConfigFileName?: string;
|
|
@@ -59,19 +124,19 @@ declare function createBuilder(options?: Partial<BuildOptions>): Promise<{
|
|
|
59
124
|
watcher: FSWatcher | undefined;
|
|
60
125
|
build(): Promise<any>;
|
|
61
126
|
watch(): any;
|
|
62
|
-
globsSet:
|
|
127
|
+
globsSet: GlobsSet;
|
|
63
128
|
}>;
|
|
64
129
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
65
130
|
watcher: FSWatcher | undefined;
|
|
66
131
|
build(): Promise<any>;
|
|
67
132
|
watch(): any;
|
|
68
|
-
globsSet:
|
|
133
|
+
globsSet: GlobsSet;
|
|
69
134
|
}>;
|
|
70
135
|
declare function watch(options?: Partial<BuildOptions>): Promise<{
|
|
71
136
|
watcher: FSWatcher | undefined;
|
|
72
137
|
build(): Promise<any>;
|
|
73
138
|
watch(): any;
|
|
74
|
-
globsSet:
|
|
139
|
+
globsSet: GlobsSet;
|
|
75
140
|
}>;
|
|
76
141
|
|
|
77
142
|
type WeappTwCosmiconfigResult = {
|
package/dist/index.d.mts
CHANGED
|
@@ -9,6 +9,17 @@ import * as cosmiconfig from 'cosmiconfig';
|
|
|
9
9
|
|
|
10
10
|
declare function createCli(): Command;
|
|
11
11
|
|
|
12
|
+
declare class GlobsSet {
|
|
13
|
+
includeSet: Set<string>;
|
|
14
|
+
excludeSet: Set<string>;
|
|
15
|
+
constructor();
|
|
16
|
+
isExcludeGlob(value: string): boolean;
|
|
17
|
+
addSingle(value: string): Set<string>;
|
|
18
|
+
add(...value: string[] | string[][]): void;
|
|
19
|
+
dump(): string[];
|
|
20
|
+
dumpIgnored(): string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
declare enum AssetType {
|
|
13
24
|
JavaScript = "javascript",
|
|
14
25
|
Json = "json",
|
|
@@ -29,25 +40,79 @@ interface GulpSassOptions extends Options<'sync'> {
|
|
|
29
40
|
sync?: boolean | undefined;
|
|
30
41
|
}
|
|
31
42
|
interface BuildOptions {
|
|
43
|
+
/**
|
|
44
|
+
* @group 0.重要配置
|
|
45
|
+
* @description 传递给 `weapp-tailwindcss` 的选项, [参考配置](/docs/api/interfaces/UserDefinedOptions)
|
|
46
|
+
*/
|
|
32
47
|
weappTailwindcssOptions: UserDefinedOptions;
|
|
48
|
+
/**
|
|
49
|
+
* @group 1.打包配置
|
|
50
|
+
* @default `dist`
|
|
51
|
+
* @description 输出目录
|
|
52
|
+
*/
|
|
33
53
|
outDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* @group 1.打包配置
|
|
56
|
+
* @default `process.cwd()`
|
|
57
|
+
* @description 根目录
|
|
58
|
+
*/
|
|
34
59
|
root: string;
|
|
60
|
+
/**
|
|
61
|
+
* @group 3.一般配置
|
|
62
|
+
* @default `true`
|
|
63
|
+
* @description build 的时候是否清除
|
|
64
|
+
*/
|
|
35
65
|
clean: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @group 1.打包配置
|
|
68
|
+
* @default `.`
|
|
69
|
+
* @description src 目录,相对路径,通常用于原生 typescript 项目
|
|
70
|
+
*/
|
|
36
71
|
src: string;
|
|
72
|
+
/**
|
|
73
|
+
* @group 1.打包配置
|
|
74
|
+
* @description 排除的文件目录
|
|
75
|
+
*/
|
|
37
76
|
exclude: string[] | ((type: AssetType) => string[]);
|
|
77
|
+
/**
|
|
78
|
+
* @group 1.打包配置
|
|
79
|
+
* @description 包括的文件目录
|
|
80
|
+
*/
|
|
38
81
|
include: string[] | ((type: AssetType) => string[]);
|
|
82
|
+
/**
|
|
83
|
+
* @group 1.打包配置
|
|
84
|
+
* @description 包括的文件后缀分类
|
|
85
|
+
*/
|
|
39
86
|
extensions: {
|
|
40
87
|
javascript?: string[];
|
|
41
88
|
html?: string[];
|
|
42
89
|
css?: string[];
|
|
43
90
|
json?: string[];
|
|
44
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* @group 1.打包配置
|
|
94
|
+
* @description postcss 配置,默认会去请求 `root` 下的 `postcss.config.js`
|
|
95
|
+
*/
|
|
45
96
|
postcssOptions?: Partial<Omit<Result, 'file'>>;
|
|
97
|
+
/**
|
|
98
|
+
* @group 2.编译支持
|
|
99
|
+
* @description 预处理配置,支持 sass 和 less,需要传入来开启编译
|
|
100
|
+
* @description 启用 sass 需要安装 sass, less 同样
|
|
101
|
+
*/
|
|
46
102
|
preprocessorOptions?: {
|
|
47
103
|
sass?: boolean | GulpSassOptions;
|
|
48
104
|
less?: boolean | GulpLessOptions;
|
|
49
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* @group 1.打包配置
|
|
108
|
+
* @description weapp-tw dev 的 watch 配置
|
|
109
|
+
*/
|
|
50
110
|
watchOptions: WatchOptions;
|
|
111
|
+
/**
|
|
112
|
+
* @group 2.编译支持
|
|
113
|
+
* @description typescript 的编译配置,默认不传伟不编译 ts
|
|
114
|
+
* @description 需要安装 typescript
|
|
115
|
+
*/
|
|
51
116
|
typescriptOptions: boolean | {
|
|
52
117
|
settings?: Settings;
|
|
53
118
|
tsConfigFileName?: string;
|
|
@@ -59,19 +124,19 @@ declare function createBuilder(options?: Partial<BuildOptions>): Promise<{
|
|
|
59
124
|
watcher: FSWatcher | undefined;
|
|
60
125
|
build(): Promise<any>;
|
|
61
126
|
watch(): any;
|
|
62
|
-
globsSet:
|
|
127
|
+
globsSet: GlobsSet;
|
|
63
128
|
}>;
|
|
64
129
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
65
130
|
watcher: FSWatcher | undefined;
|
|
66
131
|
build(): Promise<any>;
|
|
67
132
|
watch(): any;
|
|
68
|
-
globsSet:
|
|
133
|
+
globsSet: GlobsSet;
|
|
69
134
|
}>;
|
|
70
135
|
declare function watch(options?: Partial<BuildOptions>): Promise<{
|
|
71
136
|
watcher: FSWatcher | undefined;
|
|
72
137
|
build(): Promise<any>;
|
|
73
138
|
watch(): any;
|
|
74
|
-
globsSet:
|
|
139
|
+
globsSet: GlobsSet;
|
|
75
140
|
}>;
|
|
76
141
|
|
|
77
142
|
type WeappTwCosmiconfigResult = {
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,17 @@ import * as cosmiconfig from 'cosmiconfig';
|
|
|
9
9
|
|
|
10
10
|
declare function createCli(): Command;
|
|
11
11
|
|
|
12
|
+
declare class GlobsSet {
|
|
13
|
+
includeSet: Set<string>;
|
|
14
|
+
excludeSet: Set<string>;
|
|
15
|
+
constructor();
|
|
16
|
+
isExcludeGlob(value: string): boolean;
|
|
17
|
+
addSingle(value: string): Set<string>;
|
|
18
|
+
add(...value: string[] | string[][]): void;
|
|
19
|
+
dump(): string[];
|
|
20
|
+
dumpIgnored(): string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
declare enum AssetType {
|
|
13
24
|
JavaScript = "javascript",
|
|
14
25
|
Json = "json",
|
|
@@ -29,25 +40,79 @@ interface GulpSassOptions extends Options<'sync'> {
|
|
|
29
40
|
sync?: boolean | undefined;
|
|
30
41
|
}
|
|
31
42
|
interface BuildOptions {
|
|
43
|
+
/**
|
|
44
|
+
* @group 0.重要配置
|
|
45
|
+
* @description 传递给 `weapp-tailwindcss` 的选项, [参考配置](/docs/api/interfaces/UserDefinedOptions)
|
|
46
|
+
*/
|
|
32
47
|
weappTailwindcssOptions: UserDefinedOptions;
|
|
48
|
+
/**
|
|
49
|
+
* @group 1.打包配置
|
|
50
|
+
* @default `dist`
|
|
51
|
+
* @description 输出目录
|
|
52
|
+
*/
|
|
33
53
|
outDir: string;
|
|
54
|
+
/**
|
|
55
|
+
* @group 1.打包配置
|
|
56
|
+
* @default `process.cwd()`
|
|
57
|
+
* @description 根目录
|
|
58
|
+
*/
|
|
34
59
|
root: string;
|
|
60
|
+
/**
|
|
61
|
+
* @group 3.一般配置
|
|
62
|
+
* @default `true`
|
|
63
|
+
* @description build 的时候是否清除
|
|
64
|
+
*/
|
|
35
65
|
clean: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @group 1.打包配置
|
|
68
|
+
* @default `.`
|
|
69
|
+
* @description src 目录,相对路径,通常用于原生 typescript 项目
|
|
70
|
+
*/
|
|
36
71
|
src: string;
|
|
72
|
+
/**
|
|
73
|
+
* @group 1.打包配置
|
|
74
|
+
* @description 排除的文件目录
|
|
75
|
+
*/
|
|
37
76
|
exclude: string[] | ((type: AssetType) => string[]);
|
|
77
|
+
/**
|
|
78
|
+
* @group 1.打包配置
|
|
79
|
+
* @description 包括的文件目录
|
|
80
|
+
*/
|
|
38
81
|
include: string[] | ((type: AssetType) => string[]);
|
|
82
|
+
/**
|
|
83
|
+
* @group 1.打包配置
|
|
84
|
+
* @description 包括的文件后缀分类
|
|
85
|
+
*/
|
|
39
86
|
extensions: {
|
|
40
87
|
javascript?: string[];
|
|
41
88
|
html?: string[];
|
|
42
89
|
css?: string[];
|
|
43
90
|
json?: string[];
|
|
44
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* @group 1.打包配置
|
|
94
|
+
* @description postcss 配置,默认会去请求 `root` 下的 `postcss.config.js`
|
|
95
|
+
*/
|
|
45
96
|
postcssOptions?: Partial<Omit<Result, 'file'>>;
|
|
97
|
+
/**
|
|
98
|
+
* @group 2.编译支持
|
|
99
|
+
* @description 预处理配置,支持 sass 和 less,需要传入来开启编译
|
|
100
|
+
* @description 启用 sass 需要安装 sass, less 同样
|
|
101
|
+
*/
|
|
46
102
|
preprocessorOptions?: {
|
|
47
103
|
sass?: boolean | GulpSassOptions;
|
|
48
104
|
less?: boolean | GulpLessOptions;
|
|
49
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* @group 1.打包配置
|
|
108
|
+
* @description weapp-tw dev 的 watch 配置
|
|
109
|
+
*/
|
|
50
110
|
watchOptions: WatchOptions;
|
|
111
|
+
/**
|
|
112
|
+
* @group 2.编译支持
|
|
113
|
+
* @description typescript 的编译配置,默认不传伟不编译 ts
|
|
114
|
+
* @description 需要安装 typescript
|
|
115
|
+
*/
|
|
51
116
|
typescriptOptions: boolean | {
|
|
52
117
|
settings?: Settings;
|
|
53
118
|
tsConfigFileName?: string;
|
|
@@ -59,19 +124,19 @@ declare function createBuilder(options?: Partial<BuildOptions>): Promise<{
|
|
|
59
124
|
watcher: FSWatcher | undefined;
|
|
60
125
|
build(): Promise<any>;
|
|
61
126
|
watch(): any;
|
|
62
|
-
globsSet:
|
|
127
|
+
globsSet: GlobsSet;
|
|
63
128
|
}>;
|
|
64
129
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
65
130
|
watcher: FSWatcher | undefined;
|
|
66
131
|
build(): Promise<any>;
|
|
67
132
|
watch(): any;
|
|
68
|
-
globsSet:
|
|
133
|
+
globsSet: GlobsSet;
|
|
69
134
|
}>;
|
|
70
135
|
declare function watch(options?: Partial<BuildOptions>): Promise<{
|
|
71
136
|
watcher: FSWatcher | undefined;
|
|
72
137
|
build(): Promise<any>;
|
|
73
138
|
watch(): any;
|
|
74
|
-
globsSet:
|
|
139
|
+
globsSet: GlobsSet;
|
|
75
140
|
}>;
|
|
76
141
|
|
|
77
142
|
type WeappTwCosmiconfigResult = {
|
package/dist/index.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import fs, { ensureDirSync } from 'fs-extra';
|
|
|
4
4
|
import gulp from 'gulp';
|
|
5
5
|
import loadPostcssConfig from 'postcss-load-config';
|
|
6
6
|
import pc from 'picocolors';
|
|
7
|
+
import { getPackageInfo } from 'local-pkg';
|
|
7
8
|
import createDebug from 'debug';
|
|
8
9
|
import { createPlugins } from 'weapp-tailwindcss/gulp';
|
|
9
10
|
import postcssrc from 'gulp-postcss';
|
|
10
|
-
import plumber from 'gulp-plumber';
|
|
11
11
|
import gulpif from 'gulp-if';
|
|
12
12
|
import createSass from 'gulp-sass';
|
|
13
13
|
import rename from 'gulp-rename';
|
|
@@ -71,8 +71,48 @@ function createDefu(merger) {
|
|
|
71
71
|
}
|
|
72
72
|
const defu = createDefu();
|
|
73
73
|
|
|
74
|
+
const version = "0.0.0-alpha.9";
|
|
75
|
+
|
|
74
76
|
const debug = createDebug("weapp-tw-cli");
|
|
75
77
|
|
|
78
|
+
var __defProp = Object.defineProperty;
|
|
79
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
80
|
+
var __publicField = (obj, key, value) => {
|
|
81
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
82
|
+
return value;
|
|
83
|
+
};
|
|
84
|
+
class GlobsSet {
|
|
85
|
+
constructor() {
|
|
86
|
+
__publicField(this, "includeSet");
|
|
87
|
+
__publicField(this, "excludeSet");
|
|
88
|
+
this.includeSet = /* @__PURE__ */ new Set();
|
|
89
|
+
this.excludeSet = /* @__PURE__ */ new Set();
|
|
90
|
+
}
|
|
91
|
+
isExcludeGlob(value) {
|
|
92
|
+
return value[0] === "!";
|
|
93
|
+
}
|
|
94
|
+
addSingle(value) {
|
|
95
|
+
return this.isExcludeGlob(value) ? this.excludeSet.add(value) : this.includeSet.add(value);
|
|
96
|
+
}
|
|
97
|
+
add(...value) {
|
|
98
|
+
for (const v of value) {
|
|
99
|
+
if (Array.isArray(v)) {
|
|
100
|
+
for (const vv of v) {
|
|
101
|
+
this.addSingle(vv);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
this.addSingle(v);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
dump() {
|
|
109
|
+
return [...this.includeSet, ...this.excludeSet];
|
|
110
|
+
}
|
|
111
|
+
dumpIgnored() {
|
|
112
|
+
return [...this.excludeSet].map((x) => x.slice(1));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
76
116
|
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
77
117
|
AssetType2["JavaScript"] = "javascript";
|
|
78
118
|
AssetType2["Json"] = "json";
|
|
@@ -432,6 +472,23 @@ const get = /*@__PURE__*/getDefaultExportFromCjs(getValue);
|
|
|
432
472
|
function isObject(x) {
|
|
433
473
|
return typeof x === "object" && x !== null;
|
|
434
474
|
}
|
|
475
|
+
function promisify(task) {
|
|
476
|
+
return new Promise((resolve, reject) => {
|
|
477
|
+
if (Array.isArray(task)) {
|
|
478
|
+
return Promise.all(task.map((x) => promisify(x))).then(resolve).catch(reject);
|
|
479
|
+
} else {
|
|
480
|
+
if (task.destroyed) {
|
|
481
|
+
resolve(void 0);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
task.on("finish", () => {
|
|
485
|
+
resolve(void 0);
|
|
486
|
+
}).on("error", (err) => {
|
|
487
|
+
reject(err);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
435
492
|
|
|
436
493
|
function isSassLang(lang) {
|
|
437
494
|
return lang === "scss" || lang === "sass";
|
|
@@ -445,7 +502,7 @@ function isTsLang(lang) {
|
|
|
445
502
|
async function getTasks(options) {
|
|
446
503
|
let { typescriptOptions } = options;
|
|
447
504
|
const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions, preprocessorOptions } = options;
|
|
448
|
-
const globsSet =
|
|
505
|
+
const globsSet = new GlobsSet();
|
|
449
506
|
const base = srcBase ? srcBase + "/" : "";
|
|
450
507
|
const enableSass = Boolean(preprocessorOptions?.sass);
|
|
451
508
|
const enableLess = Boolean(preprocessorOptions?.less);
|
|
@@ -463,17 +520,6 @@ async function getTasks(options) {
|
|
|
463
520
|
sass = createSass(sassLib);
|
|
464
521
|
}
|
|
465
522
|
const { transformJs, transformWxml, transformWxss } = createPlugins(weappTailwindcssOptions);
|
|
466
|
-
function globsSetAdd(...value) {
|
|
467
|
-
for (const v of value) {
|
|
468
|
-
if (Array.isArray(v)) {
|
|
469
|
-
for (const vv of v) {
|
|
470
|
-
globsSet.add(vv);
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
globsSet.add(v);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
523
|
function getGlobs(type) {
|
|
478
524
|
const globs = [];
|
|
479
525
|
if (typeof include === "function") {
|
|
@@ -485,15 +531,16 @@ async function getTasks(options) {
|
|
|
485
531
|
globs.push(...exclude.map((x) => "!" + x));
|
|
486
532
|
}
|
|
487
533
|
globs.push(`!${outDir}/**/*`);
|
|
534
|
+
globs.push(`!./${outDir}/**/*`);
|
|
488
535
|
return globs;
|
|
489
536
|
}
|
|
490
537
|
function getJsTasks() {
|
|
491
538
|
const assetType = AssetType.JavaScript;
|
|
492
539
|
const globs = getGlobs(assetType);
|
|
493
|
-
|
|
540
|
+
globsSet.add(globs);
|
|
494
541
|
return extensions[assetType]?.map((x) => {
|
|
495
542
|
const src = `${base}**/*.${x}`;
|
|
496
|
-
|
|
543
|
+
globsSet.add(src);
|
|
497
544
|
const isTs = isTsLang(x);
|
|
498
545
|
const loadTs = enableTs && isTs;
|
|
499
546
|
let gulpTs;
|
|
@@ -501,27 +548,29 @@ async function getTasks(options) {
|
|
|
501
548
|
gulpTs = typescript.createProject(typescriptOptions.tsConfigFileName ?? "tsconfig.json", typeof typescriptOptions === "boolean" ? {} : typescriptOptions);
|
|
502
549
|
}
|
|
503
550
|
return function JsTask() {
|
|
504
|
-
let chain = gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsTask) })
|
|
551
|
+
let chain = gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsTask) });
|
|
505
552
|
if (loadTs) {
|
|
506
553
|
chain = chain.pipe(gulpTs());
|
|
507
554
|
}
|
|
508
|
-
return
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
555
|
+
return promisify(
|
|
556
|
+
chain.pipe(
|
|
557
|
+
transformJs({
|
|
558
|
+
babelParserOptions: !enableTs && isTs ? {
|
|
559
|
+
plugins: ["typescript"]
|
|
560
|
+
} : void 0
|
|
561
|
+
})
|
|
562
|
+
).pipe(
|
|
563
|
+
gulpif(
|
|
564
|
+
loadTs,
|
|
565
|
+
rename({
|
|
566
|
+
extname: ".js"
|
|
567
|
+
})
|
|
568
|
+
)
|
|
569
|
+
).pipe(
|
|
570
|
+
gulp.dest(outDir, {
|
|
571
|
+
cwd
|
|
519
572
|
})
|
|
520
573
|
)
|
|
521
|
-
).pipe(
|
|
522
|
-
gulp.dest(outDir, {
|
|
523
|
-
cwd
|
|
524
|
-
})
|
|
525
574
|
);
|
|
526
575
|
};
|
|
527
576
|
});
|
|
@@ -529,15 +578,17 @@ async function getTasks(options) {
|
|
|
529
578
|
function getJsonTasks() {
|
|
530
579
|
const assetType = AssetType.Json;
|
|
531
580
|
const globs = getGlobs(assetType);
|
|
532
|
-
|
|
581
|
+
globsSet.add(globs);
|
|
533
582
|
return extensions[assetType]?.map((x) => {
|
|
534
583
|
const src = `${base}**/*.${x}`;
|
|
535
|
-
|
|
584
|
+
globsSet.add(src);
|
|
536
585
|
return function JsonTask() {
|
|
537
|
-
return
|
|
538
|
-
gulp.
|
|
539
|
-
|
|
540
|
-
|
|
586
|
+
return promisify(
|
|
587
|
+
gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsonTask) }).pipe(
|
|
588
|
+
gulp.dest(outDir, {
|
|
589
|
+
cwd
|
|
590
|
+
})
|
|
591
|
+
)
|
|
541
592
|
);
|
|
542
593
|
};
|
|
543
594
|
});
|
|
@@ -545,14 +596,14 @@ async function getTasks(options) {
|
|
|
545
596
|
function getCssTasks() {
|
|
546
597
|
const assetType = AssetType.Css;
|
|
547
598
|
const globs = getGlobs(assetType);
|
|
548
|
-
|
|
599
|
+
globsSet.add(globs);
|
|
549
600
|
return extensions[assetType]?.map((x) => {
|
|
550
601
|
const src = `${base}**/*.${x}`;
|
|
551
|
-
|
|
602
|
+
globsSet.add(src);
|
|
552
603
|
const loadSass = enableSass && isSassLang(x);
|
|
553
604
|
const loadLess = enableLess && isLessLang(x);
|
|
554
605
|
return function CssTask() {
|
|
555
|
-
let chain = gulp.src([src, ...globs], { cwd, since: gulp.lastRun(CssTask) })
|
|
606
|
+
let chain = gulp.src([src, ...globs], { cwd, since: gulp.lastRun(CssTask) });
|
|
556
607
|
if (loadSass) {
|
|
557
608
|
chain = chain.pipe(
|
|
558
609
|
sass.sync(
|
|
@@ -561,17 +612,19 @@ async function getTasks(options) {
|
|
|
561
612
|
).on("error", sass.logError)
|
|
562
613
|
);
|
|
563
614
|
}
|
|
564
|
-
return
|
|
565
|
-
gulpif(
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
615
|
+
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(
|
|
617
|
+
gulpif(
|
|
618
|
+
loadSass || loadLess,
|
|
619
|
+
rename({
|
|
620
|
+
extname: ".wxss"
|
|
621
|
+
})
|
|
622
|
+
)
|
|
623
|
+
).pipe(
|
|
624
|
+
gulp.dest(outDir, {
|
|
625
|
+
cwd
|
|
569
626
|
})
|
|
570
627
|
)
|
|
571
|
-
).pipe(
|
|
572
|
-
gulp.dest(outDir, {
|
|
573
|
-
cwd
|
|
574
|
-
})
|
|
575
628
|
);
|
|
576
629
|
};
|
|
577
630
|
});
|
|
@@ -579,15 +632,17 @@ async function getTasks(options) {
|
|
|
579
632
|
function getHtmlTasks() {
|
|
580
633
|
const assetType = AssetType.Html;
|
|
581
634
|
const globs = getGlobs(assetType);
|
|
582
|
-
|
|
635
|
+
globsSet.add(globs);
|
|
583
636
|
return extensions[assetType]?.map((x) => {
|
|
584
637
|
const src = `${base}**/*.${x}`;
|
|
585
|
-
|
|
638
|
+
globsSet.add(src);
|
|
586
639
|
return function HtmlTask() {
|
|
587
|
-
return
|
|
588
|
-
gulp.
|
|
589
|
-
|
|
590
|
-
|
|
640
|
+
return promisify(
|
|
641
|
+
gulp.src([src, ...globs], { cwd, since: gulp.lastRun(HtmlTask) }).pipe(transformWxml()).pipe(
|
|
642
|
+
gulp.dest(outDir, {
|
|
643
|
+
cwd
|
|
644
|
+
})
|
|
645
|
+
)
|
|
591
646
|
);
|
|
592
647
|
};
|
|
593
648
|
});
|
|
@@ -597,11 +652,13 @@ async function getTasks(options) {
|
|
|
597
652
|
const globs = include.map((x) => {
|
|
598
653
|
return `${base}${x}`;
|
|
599
654
|
});
|
|
600
|
-
|
|
601
|
-
return
|
|
602
|
-
gulp.
|
|
603
|
-
|
|
604
|
-
|
|
655
|
+
globsSet.add(globs);
|
|
656
|
+
return promisify(
|
|
657
|
+
gulp.src(globs, { cwd, since: gulp.lastRun(copyOthers) }).pipe(
|
|
658
|
+
gulp.dest(outDir, {
|
|
659
|
+
cwd
|
|
660
|
+
})
|
|
661
|
+
)
|
|
605
662
|
);
|
|
606
663
|
}
|
|
607
664
|
}
|
|
@@ -626,7 +683,8 @@ const defaultNodeModulesDirs = [
|
|
|
626
683
|
"**/project.private.config.json/**",
|
|
627
684
|
"**/package.json/**",
|
|
628
685
|
"postcss.config.js",
|
|
629
|
-
"tailwind.config.js"
|
|
686
|
+
"tailwind.config.js",
|
|
687
|
+
"weapp-tw.config.js"
|
|
630
688
|
];
|
|
631
689
|
async function createBuilder(options) {
|
|
632
690
|
let postcssOptionsFromConfig;
|
|
@@ -647,6 +705,7 @@ async function createBuilder(options) {
|
|
|
647
705
|
json: ["json"]
|
|
648
706
|
},
|
|
649
707
|
watchOptions: {
|
|
708
|
+
cwd: options?.root,
|
|
650
709
|
events: ["add", "change", "unlink", "ready"]
|
|
651
710
|
},
|
|
652
711
|
postcssOptions: postcssOptionsFromConfig
|
|
@@ -665,10 +724,7 @@ async function createBuilder(options) {
|
|
|
665
724
|
if (value) {
|
|
666
725
|
debug(`run task ${pc.bold(pc.green(key))} start`);
|
|
667
726
|
for (const task of value) {
|
|
668
|
-
|
|
669
|
-
if (s) {
|
|
670
|
-
await new Promise((resolve, reject) => s.on("finish", resolve).on("error", reject));
|
|
671
|
-
}
|
|
727
|
+
await task();
|
|
672
728
|
}
|
|
673
729
|
debug(`run task ${pc.bold(pc.green(key))} end`);
|
|
674
730
|
}
|
|
@@ -692,7 +748,10 @@ async function createBuilder(options) {
|
|
|
692
748
|
},
|
|
693
749
|
watch() {
|
|
694
750
|
ensureDirSync(path.resolve(cwd, outDir));
|
|
695
|
-
const
|
|
751
|
+
const dumps = globsSet.dump();
|
|
752
|
+
const arr = (Array.isArray(watchOptions.ignored) ? watchOptions.ignored : [watchOptions.ignored]).filter(Boolean);
|
|
753
|
+
watchOptions.ignored = [...globsSet.dumpIgnored(), ...arr];
|
|
754
|
+
const watcher = gulp.watch(dumps, watchOptions, async (cb) => {
|
|
696
755
|
try {
|
|
697
756
|
await runTasks();
|
|
698
757
|
cb();
|
|
@@ -709,8 +768,13 @@ async function createBuilder(options) {
|
|
|
709
768
|
watcher.on("unlink", function(path2) {
|
|
710
769
|
console.log(`${pc.green("remove")} ${path2}`);
|
|
711
770
|
});
|
|
712
|
-
watcher.on("ready", function() {
|
|
713
|
-
|
|
771
|
+
watcher.on("ready", async function() {
|
|
772
|
+
const meta = await getPackageInfo("weapp-tailwindcss");
|
|
773
|
+
let weappTwVersionStr = "";
|
|
774
|
+
if (meta) {
|
|
775
|
+
weappTwVersionStr = `(${pc.blue(pc.underline(meta.version))})`;
|
|
776
|
+
}
|
|
777
|
+
console.log(`${pc.bold(`${pc.green("weapp")}-${pc.blue("tailwindcss")}`)}${weappTwVersionStr} ${pc.cyan("cli")}(${pc.blue(pc.underline(version))}) is ready!`);
|
|
714
778
|
});
|
|
715
779
|
this.watcher = watcher;
|
|
716
780
|
return this;
|
|
@@ -800,6 +864,7 @@ function updatePackageJson(options) {
|
|
|
800
864
|
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
801
865
|
set(packageJson, "scripts.dev", "weapp-tw dev");
|
|
802
866
|
set(packageJson, "scripts.build", "weapp-tw build");
|
|
867
|
+
set(packageJson, "scripts.postinstall", "weapp-tw patch");
|
|
803
868
|
fs.outputJSONSync(dest ?? packageJsonPath, packageJson, {
|
|
804
869
|
spaces: 2
|
|
805
870
|
});
|
|
@@ -830,7 +895,9 @@ export default defineConfig(${configOptionsStr})
|
|
|
830
895
|
fs.writeFileSync(
|
|
831
896
|
configPath,
|
|
832
897
|
`/** @type {import('@weapp-tailwindcss/cli').UserConfig} */
|
|
833
|
-
|
|
898
|
+
const config = ${configOptionsStr}
|
|
899
|
+
|
|
900
|
+
module.exports = config
|
|
834
901
|
`,
|
|
835
902
|
"utf8"
|
|
836
903
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/cli",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.9",
|
|
4
4
|
"description": "The cli of weapp-tailwindcss",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"weapp",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"author": "SonOfMagic <qq1324318532@gmail.com>",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/sonofmagic/weapp-tailwindcss
|
|
14
|
+
"url": "https://github.com/sonofmagic/weapp-tailwindcss/issues"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://weapp-tw.icebreaker.top",
|
|
16
|
+
"homepage": "https://weapp-tw.icebreaker.top/docs/quick-start/native/install",
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"type": "commonjs",
|
|
19
19
|
"exports": {
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"debug": "4.3.4",
|
|
36
36
|
"del": "^7.1.0",
|
|
37
37
|
"fs-extra": "^11.2.0",
|
|
38
|
-
"gulp": "^
|
|
38
|
+
"gulp": "^4.0.2",
|
|
39
|
+
"gulp-debug": "^5.0.1",
|
|
39
40
|
"gulp-if": "^3.0.0",
|
|
40
41
|
"gulp-less": "^5.0.0",
|
|
41
42
|
"gulp-plumber": "^1.2.1",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"gulp-rename": "^2.0.0",
|
|
44
45
|
"gulp-sass": "^5.1.0",
|
|
45
46
|
"gulp-typescript": "6.0.0-alpha.1",
|
|
47
|
+
"local-pkg": "^0.5.0",
|
|
46
48
|
"picocolors": "^1.0.0",
|
|
47
49
|
"postcss": "^8.4.38",
|
|
48
50
|
"postcss-load-config": "^5.0.3"
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
"less": "*",
|
|
52
54
|
"sass": "*",
|
|
53
55
|
"typescript": "*",
|
|
54
|
-
"weapp-tailwindcss": "3.2.0-alpha.
|
|
56
|
+
"weapp-tailwindcss": "3.2.0-alpha.10"
|
|
55
57
|
},
|
|
56
58
|
"peerDependenciesMeta": {
|
|
57
59
|
"less": {
|