@weapp-tailwindcss/cli 0.0.0-alpha.1 → 0.0.0-alpha.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 +36 -6
- package/dist/index.d.cts +14 -3
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.mjs +37 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ const commander = require('commander');
|
|
|
4
4
|
const loadPostcssConfig = require('postcss-load-config');
|
|
5
5
|
const path = require('node:path');
|
|
6
6
|
const fs = require('fs-extra');
|
|
7
|
-
const gulp = require('weapp-tailwindcss/gulp');
|
|
8
7
|
const gulp$1 = require('gulp');
|
|
8
|
+
const gulp = require('weapp-tailwindcss/gulp');
|
|
9
9
|
const cosmiconfig = require('cosmiconfig');
|
|
10
10
|
|
|
11
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -215,7 +215,8 @@ function createBuilder(options) {
|
|
|
215
215
|
clean,
|
|
216
216
|
extensions,
|
|
217
217
|
exclude,
|
|
218
|
-
include
|
|
218
|
+
include,
|
|
219
|
+
watchOptions
|
|
219
220
|
} = defu(options, {
|
|
220
221
|
outDir: "dist",
|
|
221
222
|
weappTailwindcssOptions: {},
|
|
@@ -237,17 +238,19 @@ function createBuilder(options) {
|
|
|
237
238
|
clean,
|
|
238
239
|
extensions,
|
|
239
240
|
exclude,
|
|
240
|
-
include
|
|
241
|
+
include,
|
|
242
|
+
watchOptions
|
|
241
243
|
});
|
|
242
244
|
const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
|
|
243
245
|
return {
|
|
246
|
+
watcher: void 0,
|
|
244
247
|
async build() {
|
|
245
248
|
if (clean) {
|
|
246
249
|
const { deleteAsync } = await import('del');
|
|
247
250
|
const patterns = [outDir + "/**"];
|
|
248
251
|
await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
|
|
249
252
|
}
|
|
250
|
-
|
|
253
|
+
fs.ensureDirSync(path__default.resolve(cwd, outDir));
|
|
251
254
|
for (const task of tasks) {
|
|
252
255
|
const s = task();
|
|
253
256
|
if (s) {
|
|
@@ -256,8 +259,19 @@ function createBuilder(options) {
|
|
|
256
259
|
}
|
|
257
260
|
return this;
|
|
258
261
|
},
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
watch() {
|
|
263
|
+
fs.ensureDirSync(path__default.resolve(cwd, outDir));
|
|
264
|
+
const watcher = gulp__default.watch([...globsSet], watchOptions, gulp__default.parallel(...tasks));
|
|
265
|
+
watcher.on("change", function(path2) {
|
|
266
|
+
console.log(`File ${path2} was changed`);
|
|
267
|
+
});
|
|
268
|
+
watcher.on("add", function(path2) {
|
|
269
|
+
console.log(`File ${path2} was added`);
|
|
270
|
+
});
|
|
271
|
+
watcher.on("unlink", function(path2) {
|
|
272
|
+
console.log(`File ${path2} was removed`);
|
|
273
|
+
});
|
|
274
|
+
this.watcher = watcher;
|
|
261
275
|
return this;
|
|
262
276
|
},
|
|
263
277
|
globsSet
|
|
@@ -267,6 +281,10 @@ function build(options) {
|
|
|
267
281
|
const builder = createBuilder(options);
|
|
268
282
|
return builder.build();
|
|
269
283
|
}
|
|
284
|
+
function watch(options) {
|
|
285
|
+
const builder = createBuilder(options);
|
|
286
|
+
return builder.watch();
|
|
287
|
+
}
|
|
270
288
|
|
|
271
289
|
function getDefaultExportFromCjs (x) {
|
|
272
290
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -731,6 +749,17 @@ function createCli() {
|
|
|
731
749
|
const configLoader = createConfigLoader(cwd);
|
|
732
750
|
const userDefinedConfig = configLoader.search(cwd);
|
|
733
751
|
program.command("dev").alias("serve").action(async () => {
|
|
752
|
+
const postcssOptions = await loadPostcssConfig__default({
|
|
753
|
+
cwd
|
|
754
|
+
});
|
|
755
|
+
await watch(
|
|
756
|
+
defu(userDefinedConfig?.config, {
|
|
757
|
+
root: cwd,
|
|
758
|
+
weappTailwindcssOptions: {
|
|
759
|
+
postcssOptions
|
|
760
|
+
}
|
|
761
|
+
})
|
|
762
|
+
);
|
|
734
763
|
});
|
|
735
764
|
program.command("build").action(async () => {
|
|
736
765
|
const postcssOptions = await loadPostcssConfig__default({
|
|
@@ -758,3 +787,4 @@ exports.createBuilder = createBuilder;
|
|
|
758
787
|
exports.createCli = createCli;
|
|
759
788
|
exports.createConfigLoader = createConfigLoader;
|
|
760
789
|
exports.defineConfig = defineConfig;
|
|
790
|
+
exports.watch = watch;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { FSWatcher } from 'fs-extra';
|
|
2
3
|
import { UserDefinedOptions } from 'weapp-tailwindcss';
|
|
4
|
+
import { WatchOptions } from 'gulp';
|
|
3
5
|
import * as cosmiconfig from 'cosmiconfig';
|
|
4
6
|
|
|
5
7
|
declare function createCli(): Command;
|
|
@@ -25,18 +27,27 @@ interface BuildOptions {
|
|
|
25
27
|
css: string[];
|
|
26
28
|
json: string[];
|
|
27
29
|
};
|
|
30
|
+
watchOptions: WatchOptions;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
declare function createBuilder(options?: Partial<BuildOptions>): {
|
|
34
|
+
watcher: FSWatcher | undefined;
|
|
31
35
|
build(): Promise<any>;
|
|
32
|
-
watch():
|
|
36
|
+
watch(): any;
|
|
33
37
|
globsSet: Set<string>;
|
|
34
38
|
};
|
|
35
39
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
40
|
+
watcher: FSWatcher | undefined;
|
|
36
41
|
build(): Promise<any>;
|
|
37
|
-
watch():
|
|
42
|
+
watch(): any;
|
|
38
43
|
globsSet: Set<string>;
|
|
39
44
|
}>;
|
|
45
|
+
declare function watch(options?: Partial<BuildOptions>): {
|
|
46
|
+
watcher: FSWatcher | undefined;
|
|
47
|
+
build(): Promise<any>;
|
|
48
|
+
watch(): any;
|
|
49
|
+
globsSet: Set<string>;
|
|
50
|
+
};
|
|
40
51
|
|
|
41
52
|
type WeappTwCosmiconfigResult = {
|
|
42
53
|
config: UserConfig;
|
|
@@ -56,4 +67,4 @@ type UserConfig = {
|
|
|
56
67
|
};
|
|
57
68
|
declare function defineConfig(options: UserConfig): UserConfig;
|
|
58
69
|
|
|
59
|
-
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig };
|
|
70
|
+
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { FSWatcher } from 'fs-extra';
|
|
2
3
|
import { UserDefinedOptions } from 'weapp-tailwindcss';
|
|
4
|
+
import { WatchOptions } from 'gulp';
|
|
3
5
|
import * as cosmiconfig from 'cosmiconfig';
|
|
4
6
|
|
|
5
7
|
declare function createCli(): Command;
|
|
@@ -25,18 +27,27 @@ interface BuildOptions {
|
|
|
25
27
|
css: string[];
|
|
26
28
|
json: string[];
|
|
27
29
|
};
|
|
30
|
+
watchOptions: WatchOptions;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
declare function createBuilder(options?: Partial<BuildOptions>): {
|
|
34
|
+
watcher: FSWatcher | undefined;
|
|
31
35
|
build(): Promise<any>;
|
|
32
|
-
watch():
|
|
36
|
+
watch(): any;
|
|
33
37
|
globsSet: Set<string>;
|
|
34
38
|
};
|
|
35
39
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
40
|
+
watcher: FSWatcher | undefined;
|
|
36
41
|
build(): Promise<any>;
|
|
37
|
-
watch():
|
|
42
|
+
watch(): any;
|
|
38
43
|
globsSet: Set<string>;
|
|
39
44
|
}>;
|
|
45
|
+
declare function watch(options?: Partial<BuildOptions>): {
|
|
46
|
+
watcher: FSWatcher | undefined;
|
|
47
|
+
build(): Promise<any>;
|
|
48
|
+
watch(): any;
|
|
49
|
+
globsSet: Set<string>;
|
|
50
|
+
};
|
|
40
51
|
|
|
41
52
|
type WeappTwCosmiconfigResult = {
|
|
42
53
|
config: UserConfig;
|
|
@@ -56,4 +67,4 @@ type UserConfig = {
|
|
|
56
67
|
};
|
|
57
68
|
declare function defineConfig(options: UserConfig): UserConfig;
|
|
58
69
|
|
|
59
|
-
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig };
|
|
70
|
+
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { FSWatcher } from 'fs-extra';
|
|
2
3
|
import { UserDefinedOptions } from 'weapp-tailwindcss';
|
|
4
|
+
import { WatchOptions } from 'gulp';
|
|
3
5
|
import * as cosmiconfig from 'cosmiconfig';
|
|
4
6
|
|
|
5
7
|
declare function createCli(): Command;
|
|
@@ -25,18 +27,27 @@ interface BuildOptions {
|
|
|
25
27
|
css: string[];
|
|
26
28
|
json: string[];
|
|
27
29
|
};
|
|
30
|
+
watchOptions: WatchOptions;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
declare function createBuilder(options?: Partial<BuildOptions>): {
|
|
34
|
+
watcher: FSWatcher | undefined;
|
|
31
35
|
build(): Promise<any>;
|
|
32
|
-
watch():
|
|
36
|
+
watch(): any;
|
|
33
37
|
globsSet: Set<string>;
|
|
34
38
|
};
|
|
35
39
|
declare function build(options?: Partial<BuildOptions>): Promise<{
|
|
40
|
+
watcher: FSWatcher | undefined;
|
|
36
41
|
build(): Promise<any>;
|
|
37
|
-
watch():
|
|
42
|
+
watch(): any;
|
|
38
43
|
globsSet: Set<string>;
|
|
39
44
|
}>;
|
|
45
|
+
declare function watch(options?: Partial<BuildOptions>): {
|
|
46
|
+
watcher: FSWatcher | undefined;
|
|
47
|
+
build(): Promise<any>;
|
|
48
|
+
watch(): any;
|
|
49
|
+
globsSet: Set<string>;
|
|
50
|
+
};
|
|
40
51
|
|
|
41
52
|
type WeappTwCosmiconfigResult = {
|
|
42
53
|
config: UserConfig;
|
|
@@ -56,4 +67,4 @@ type UserConfig = {
|
|
|
56
67
|
};
|
|
57
68
|
declare function defineConfig(options: UserConfig): UserConfig;
|
|
58
69
|
|
|
59
|
-
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig };
|
|
70
|
+
export { type UserConfig, build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import loadPostcssConfig from 'postcss-load-config';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import fs, {
|
|
5
|
-
import { createPlugins } from 'weapp-tailwindcss/gulp';
|
|
4
|
+
import fs, { ensureDirSync } from 'fs-extra';
|
|
6
5
|
import gulp from 'gulp';
|
|
6
|
+
import { createPlugins } from 'weapp-tailwindcss/gulp';
|
|
7
7
|
import { cosmiconfigSync } from 'cosmiconfig';
|
|
8
8
|
|
|
9
9
|
function isPlainObject$2(value) {
|
|
@@ -206,7 +206,8 @@ function createBuilder(options) {
|
|
|
206
206
|
clean,
|
|
207
207
|
extensions,
|
|
208
208
|
exclude,
|
|
209
|
-
include
|
|
209
|
+
include,
|
|
210
|
+
watchOptions
|
|
210
211
|
} = defu(options, {
|
|
211
212
|
outDir: "dist",
|
|
212
213
|
weappTailwindcssOptions: {},
|
|
@@ -228,17 +229,19 @@ function createBuilder(options) {
|
|
|
228
229
|
clean,
|
|
229
230
|
extensions,
|
|
230
231
|
exclude,
|
|
231
|
-
include
|
|
232
|
+
include,
|
|
233
|
+
watchOptions
|
|
232
234
|
});
|
|
233
235
|
const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
|
|
234
236
|
return {
|
|
237
|
+
watcher: void 0,
|
|
235
238
|
async build() {
|
|
236
239
|
if (clean) {
|
|
237
240
|
const { deleteAsync } = await import('del');
|
|
238
241
|
const patterns = [outDir + "/**"];
|
|
239
242
|
await deleteAsync(patterns, { cwd, ignore: defaultNodeModulesDirs });
|
|
240
243
|
}
|
|
241
|
-
|
|
244
|
+
ensureDirSync(path.resolve(cwd, outDir));
|
|
242
245
|
for (const task of tasks) {
|
|
243
246
|
const s = task();
|
|
244
247
|
if (s) {
|
|
@@ -247,8 +250,19 @@ function createBuilder(options) {
|
|
|
247
250
|
}
|
|
248
251
|
return this;
|
|
249
252
|
},
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
watch() {
|
|
254
|
+
ensureDirSync(path.resolve(cwd, outDir));
|
|
255
|
+
const watcher = gulp.watch([...globsSet], watchOptions, gulp.parallel(...tasks));
|
|
256
|
+
watcher.on("change", function(path2) {
|
|
257
|
+
console.log(`File ${path2} was changed`);
|
|
258
|
+
});
|
|
259
|
+
watcher.on("add", function(path2) {
|
|
260
|
+
console.log(`File ${path2} was added`);
|
|
261
|
+
});
|
|
262
|
+
watcher.on("unlink", function(path2) {
|
|
263
|
+
console.log(`File ${path2} was removed`);
|
|
264
|
+
});
|
|
265
|
+
this.watcher = watcher;
|
|
252
266
|
return this;
|
|
253
267
|
},
|
|
254
268
|
globsSet
|
|
@@ -258,6 +272,10 @@ function build(options) {
|
|
|
258
272
|
const builder = createBuilder(options);
|
|
259
273
|
return builder.build();
|
|
260
274
|
}
|
|
275
|
+
function watch(options) {
|
|
276
|
+
const builder = createBuilder(options);
|
|
277
|
+
return builder.watch();
|
|
278
|
+
}
|
|
261
279
|
|
|
262
280
|
function getDefaultExportFromCjs (x) {
|
|
263
281
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -722,6 +740,17 @@ function createCli() {
|
|
|
722
740
|
const configLoader = createConfigLoader(cwd);
|
|
723
741
|
const userDefinedConfig = configLoader.search(cwd);
|
|
724
742
|
program.command("dev").alias("serve").action(async () => {
|
|
743
|
+
const postcssOptions = await loadPostcssConfig({
|
|
744
|
+
cwd
|
|
745
|
+
});
|
|
746
|
+
await watch(
|
|
747
|
+
defu(userDefinedConfig?.config, {
|
|
748
|
+
root: cwd,
|
|
749
|
+
weappTailwindcssOptions: {
|
|
750
|
+
postcssOptions
|
|
751
|
+
}
|
|
752
|
+
})
|
|
753
|
+
);
|
|
725
754
|
});
|
|
726
755
|
program.command("build").action(async () => {
|
|
727
756
|
const postcssOptions = await loadPostcssConfig({
|
|
@@ -744,4 +773,4 @@ function createCli() {
|
|
|
744
773
|
return program;
|
|
745
774
|
}
|
|
746
775
|
|
|
747
|
-
export { build, createBuilder, createCli, createConfigLoader, defineConfig };
|
|
776
|
+
export { build, createBuilder, createCli, createConfigLoader, defineConfig, watch };
|