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

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,19 +1,25 @@
1
1
  'use strict';
2
2
 
3
3
  const commander = require('commander');
4
- const loadPostcssConfig = require('postcss-load-config');
5
4
  const path = require('node:path');
6
5
  const fs = require('fs-extra');
7
6
  const gulp$1 = require('gulp');
7
+ const loadPostcssConfig = require('postcss-load-config');
8
8
  const gulp = require('weapp-tailwindcss/gulp');
9
+ const postcssrc = require('gulp-postcss');
10
+ const plumber = require('gulp-plumber');
11
+ const gulpif = require('gulp-if');
9
12
  const cosmiconfig = require('cosmiconfig');
10
13
 
11
14
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
15
 
13
- const loadPostcssConfig__default = /*#__PURE__*/_interopDefaultCompat(loadPostcssConfig);
14
16
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
15
17
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
16
18
  const gulp__default = /*#__PURE__*/_interopDefaultCompat(gulp$1);
19
+ const loadPostcssConfig__default = /*#__PURE__*/_interopDefaultCompat(loadPostcssConfig);
20
+ const postcssrc__default = /*#__PURE__*/_interopDefaultCompat(postcssrc);
21
+ const plumber__default = /*#__PURE__*/_interopDefaultCompat(plumber);
22
+ const gulpif__default = /*#__PURE__*/_interopDefaultCompat(gulpif);
17
23
 
18
24
  function isPlainObject$2(value) {
19
25
  if (value === null || typeof value !== "object") {
@@ -80,7 +86,7 @@ var AssetType = /* @__PURE__ */ ((AssetType2) => {
80
86
  })(AssetType || {});
81
87
 
82
88
  function getTasks(options) {
83
- const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include } = options;
89
+ const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions } = options;
84
90
  const globsSet = /* @__PURE__ */ new Set();
85
91
  const base = srcBase ? srcBase + "/" : "";
86
92
  function globsSetAdd(...value) {
@@ -115,17 +121,19 @@ function getTasks(options) {
115
121
  return extensions[assetType].map((x) => {
116
122
  const src = `${base}**/*.${x}`;
117
123
  globsSetAdd(src);
118
- return () => gulp__default.src([src, ...globs], { cwd }).pipe(
119
- transformJs({
120
- babelParserOptions: x === "ts" ? {
121
- plugins: ["typescript"]
122
- } : void 0
123
- })
124
- ).pipe(
125
- gulp__default.dest(outDir, {
126
- cwd
127
- })
128
- );
124
+ return function JsTask() {
125
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsTask) }).pipe(plumber__default()).pipe(
126
+ transformJs({
127
+ babelParserOptions: x === "ts" ? {
128
+ plugins: ["typescript"]
129
+ } : void 0
130
+ })
131
+ ).pipe(
132
+ gulp__default.dest(outDir, {
133
+ cwd
134
+ })
135
+ );
136
+ };
129
137
  });
130
138
  }
131
139
  function getJsonTasks() {
@@ -135,11 +143,13 @@ function getTasks(options) {
135
143
  return extensions[assetType].map((x) => {
136
144
  const src = `${base}**/*.${x}`;
137
145
  globsSetAdd(src);
138
- return () => gulp__default.src([src, ...globs], { cwd }).pipe(
139
- gulp__default.dest(outDir, {
140
- cwd
141
- })
142
- );
146
+ return function JsonTask() {
147
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(JsonTask) }).pipe(plumber__default()).pipe(
148
+ gulp__default.dest(outDir, {
149
+ cwd
150
+ })
151
+ );
152
+ };
143
153
  });
144
154
  }
145
155
  function getCssTasks() {
@@ -149,11 +159,13 @@ function getTasks(options) {
149
159
  return extensions[assetType].map((x) => {
150
160
  const src = `${base}**/*.${x}`;
151
161
  globsSetAdd(src);
152
- return () => gulp__default.src([src, ...globs], { cwd }).pipe(transformWxss()).pipe(
153
- gulp__default.dest(outDir, {
154
- cwd
155
- })
156
- );
162
+ return function CssTask() {
163
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(CssTask) }).pipe(plumber__default()).pipe(gulpif__default(Boolean(postcssOptions), postcssrc__default(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
164
+ gulp__default.dest(outDir, {
165
+ cwd
166
+ })
167
+ );
168
+ };
157
169
  });
158
170
  }
159
171
  function getHtmlTasks() {
@@ -163,11 +175,13 @@ function getTasks(options) {
163
175
  return extensions[assetType].map((x) => {
164
176
  const src = `${base}**/*.${x}`;
165
177
  globsSetAdd(src);
166
- return () => gulp__default.src([src, ...globs], { cwd }).pipe(transformWxml()).pipe(
167
- gulp__default.dest(outDir, {
168
- cwd
169
- })
170
- );
178
+ return function HtmlTask() {
179
+ return gulp__default.src([src, ...globs], { cwd, since: gulp__default.lastRun(HtmlTask) }).pipe(plumber__default()).pipe(transformWxml()).pipe(
180
+ gulp__default.dest(outDir, {
181
+ cwd
182
+ })
183
+ );
184
+ };
171
185
  });
172
186
  }
173
187
  function copyOthers() {
@@ -176,7 +190,7 @@ function getTasks(options) {
176
190
  return `${base}${x}`;
177
191
  });
178
192
  globsSetAdd(globs);
179
- return gulp__default.src(globs, { cwd }).pipe(
193
+ return gulp__default.src(globs, { cwd, since: gulp__default.lastRun(copyOthers) }).pipe(plumber__default()).pipe(
180
194
  gulp__default.dest(outDir, {
181
195
  cwd
182
196
  })
@@ -216,7 +230,8 @@ function createBuilder(options) {
216
230
  extensions,
217
231
  exclude,
218
232
  include,
219
- watchOptions
233
+ watchOptions,
234
+ postcssOptions
220
235
  } = defu(options, {
221
236
  outDir: "dist",
222
237
  weappTailwindcssOptions: {},
@@ -228,6 +243,9 @@ function createBuilder(options) {
228
243
  html: ["wxml"],
229
244
  css: ["wxss", "less", "sass", "scss"],
230
245
  json: ["json"]
246
+ },
247
+ watchOptions: {
248
+ events: ["add", "change", "unlink", "ready"]
231
249
  }
232
250
  });
233
251
  const { copyOthers, getCssTasks, getHtmlTasks, getJsTasks, getJsonTasks, globsSet } = getTasks({
@@ -239,7 +257,8 @@ function createBuilder(options) {
239
257
  extensions,
240
258
  exclude,
241
259
  include,
242
- watchOptions
260
+ watchOptions,
261
+ postcssOptions
243
262
  });
244
263
  const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
245
264
  async function runTasks() {
@@ -281,19 +300,32 @@ function createBuilder(options) {
281
300
  watcher.on("unlink", function(path2) {
282
301
  console.log(`File ${path2} was removed`);
283
302
  });
303
+ watcher.on("ready", function() {
304
+ console.log(`Weapp-tailwindcss is Ready!`);
305
+ });
284
306
  this.watcher = watcher;
285
307
  return this;
286
308
  },
287
309
  globsSet
288
310
  };
289
311
  }
290
- function build(options) {
291
- const builder = createBuilder(options);
292
- return builder.build();
312
+ async function build(options) {
313
+ let postcssOptions;
314
+ try {
315
+ postcssOptions = await loadPostcssConfig__default({ cwd: options?.root });
316
+ } catch {
317
+ }
318
+ const builder = createBuilder(defu(options, { postcssOptions }));
319
+ return await builder.build();
293
320
  }
294
- function watch(options) {
295
- const builder = createBuilder(options);
296
- return builder.watch();
321
+ async function watch(options) {
322
+ let postcssOptions;
323
+ try {
324
+ postcssOptions = await loadPostcssConfig__default({ cwd: options?.root });
325
+ } catch {
326
+ }
327
+ const builder = createBuilder(defu(options, { postcssOptions }));
328
+ return await builder.watch();
297
329
  }
298
330
 
299
331
  function getDefaultExportFromCjs (x) {
@@ -759,28 +791,16 @@ function createCli() {
759
791
  const configLoader = createConfigLoader(cwd);
760
792
  const userDefinedConfig = configLoader.search(cwd);
761
793
  program.command("dev").alias("serve").action(async () => {
762
- const postcssOptions = await loadPostcssConfig__default({
763
- cwd
764
- });
765
794
  await watch(
766
795
  defu(userDefinedConfig?.config, {
767
- root: cwd,
768
- weappTailwindcssOptions: {
769
- postcssOptions
770
- }
796
+ root: cwd
771
797
  })
772
798
  );
773
799
  });
774
800
  program.command("build").action(async () => {
775
- const postcssOptions = await loadPostcssConfig__default({
776
- cwd
777
- });
778
801
  await build(
779
802
  defu(userDefinedConfig?.config, {
780
- root: cwd,
781
- weappTailwindcssOptions: {
782
- postcssOptions
783
- }
803
+ root: cwd
784
804
  })
785
805
  );
786
806
  });
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { FSWatcher } from 'fs-extra';
3
3
  import { UserDefinedOptions } from 'weapp-tailwindcss';
4
4
  import { WatchOptions } from 'gulp';
5
+ import { Result } from 'postcss-load-config';
5
6
  import * as cosmiconfig from 'cosmiconfig';
6
7
 
7
8
  declare function createCli(): Command;
@@ -27,6 +28,7 @@ interface BuildOptions {
27
28
  css: string[];
28
29
  json: string[];
29
30
  };
31
+ postcssOptions?: Partial<Omit<Result, 'file'>>;
30
32
  watchOptions: WatchOptions;
31
33
  }
32
34
 
@@ -42,12 +44,12 @@ declare function build(options?: Partial<BuildOptions>): Promise<{
42
44
  watch(): any;
43
45
  globsSet: Set<string>;
44
46
  }>;
45
- declare function watch(options?: Partial<BuildOptions>): {
47
+ declare function watch(options?: Partial<BuildOptions>): Promise<{
46
48
  watcher: FSWatcher | undefined;
47
49
  build(): Promise<any>;
48
50
  watch(): any;
49
51
  globsSet: Set<string>;
50
- };
52
+ }>;
51
53
 
52
54
  type WeappTwCosmiconfigResult = {
53
55
  config: UserConfig;
package/dist/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { FSWatcher } from 'fs-extra';
3
3
  import { UserDefinedOptions } from 'weapp-tailwindcss';
4
4
  import { WatchOptions } from 'gulp';
5
+ import { Result } from 'postcss-load-config';
5
6
  import * as cosmiconfig from 'cosmiconfig';
6
7
 
7
8
  declare function createCli(): Command;
@@ -27,6 +28,7 @@ interface BuildOptions {
27
28
  css: string[];
28
29
  json: string[];
29
30
  };
31
+ postcssOptions?: Partial<Omit<Result, 'file'>>;
30
32
  watchOptions: WatchOptions;
31
33
  }
32
34
 
@@ -42,12 +44,12 @@ declare function build(options?: Partial<BuildOptions>): Promise<{
42
44
  watch(): any;
43
45
  globsSet: Set<string>;
44
46
  }>;
45
- declare function watch(options?: Partial<BuildOptions>): {
47
+ declare function watch(options?: Partial<BuildOptions>): Promise<{
46
48
  watcher: FSWatcher | undefined;
47
49
  build(): Promise<any>;
48
50
  watch(): any;
49
51
  globsSet: Set<string>;
50
- };
52
+ }>;
51
53
 
52
54
  type WeappTwCosmiconfigResult = {
53
55
  config: UserConfig;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Command } from 'commander';
2
2
  import { FSWatcher } from 'fs-extra';
3
3
  import { UserDefinedOptions } from 'weapp-tailwindcss';
4
4
  import { WatchOptions } from 'gulp';
5
+ import { Result } from 'postcss-load-config';
5
6
  import * as cosmiconfig from 'cosmiconfig';
6
7
 
7
8
  declare function createCli(): Command;
@@ -27,6 +28,7 @@ interface BuildOptions {
27
28
  css: string[];
28
29
  json: string[];
29
30
  };
31
+ postcssOptions?: Partial<Omit<Result, 'file'>>;
30
32
  watchOptions: WatchOptions;
31
33
  }
32
34
 
@@ -42,12 +44,12 @@ declare function build(options?: Partial<BuildOptions>): Promise<{
42
44
  watch(): any;
43
45
  globsSet: Set<string>;
44
46
  }>;
45
- declare function watch(options?: Partial<BuildOptions>): {
47
+ declare function watch(options?: Partial<BuildOptions>): Promise<{
46
48
  watcher: FSWatcher | undefined;
47
49
  build(): Promise<any>;
48
50
  watch(): any;
49
51
  globsSet: Set<string>;
50
- };
52
+ }>;
51
53
 
52
54
  type WeappTwCosmiconfigResult = {
53
55
  config: UserConfig;
package/dist/index.mjs CHANGED
@@ -1,9 +1,12 @@
1
1
  import { Command } from 'commander';
2
- import loadPostcssConfig from 'postcss-load-config';
3
2
  import path from 'node:path';
4
3
  import fs, { ensureDirSync } from 'fs-extra';
5
4
  import gulp from 'gulp';
5
+ import loadPostcssConfig from 'postcss-load-config';
6
6
  import { createPlugins } from 'weapp-tailwindcss/gulp';
7
+ import postcssrc from 'gulp-postcss';
8
+ import plumber from 'gulp-plumber';
9
+ import gulpif from 'gulp-if';
7
10
  import { cosmiconfigSync } from 'cosmiconfig';
8
11
 
9
12
  function isPlainObject$2(value) {
@@ -71,7 +74,7 @@ var AssetType = /* @__PURE__ */ ((AssetType2) => {
71
74
  })(AssetType || {});
72
75
 
73
76
  function getTasks(options) {
74
- const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include } = options;
77
+ const { root: cwd, weappTailwindcssOptions, outDir, src: srcBase, extensions, exclude, include, postcssOptions } = options;
75
78
  const globsSet = /* @__PURE__ */ new Set();
76
79
  const base = srcBase ? srcBase + "/" : "";
77
80
  function globsSetAdd(...value) {
@@ -106,17 +109,19 @@ function getTasks(options) {
106
109
  return extensions[assetType].map((x) => {
107
110
  const src = `${base}**/*.${x}`;
108
111
  globsSetAdd(src);
109
- return () => gulp.src([src, ...globs], { cwd }).pipe(
110
- transformJs({
111
- babelParserOptions: x === "ts" ? {
112
- plugins: ["typescript"]
113
- } : void 0
114
- })
115
- ).pipe(
116
- gulp.dest(outDir, {
117
- cwd
118
- })
119
- );
112
+ return function JsTask() {
113
+ return gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsTask) }).pipe(plumber()).pipe(
114
+ transformJs({
115
+ babelParserOptions: x === "ts" ? {
116
+ plugins: ["typescript"]
117
+ } : void 0
118
+ })
119
+ ).pipe(
120
+ gulp.dest(outDir, {
121
+ cwd
122
+ })
123
+ );
124
+ };
120
125
  });
121
126
  }
122
127
  function getJsonTasks() {
@@ -126,11 +131,13 @@ function getTasks(options) {
126
131
  return extensions[assetType].map((x) => {
127
132
  const src = `${base}**/*.${x}`;
128
133
  globsSetAdd(src);
129
- return () => gulp.src([src, ...globs], { cwd }).pipe(
130
- gulp.dest(outDir, {
131
- cwd
132
- })
133
- );
134
+ return function JsonTask() {
135
+ return gulp.src([src, ...globs], { cwd, since: gulp.lastRun(JsonTask) }).pipe(plumber()).pipe(
136
+ gulp.dest(outDir, {
137
+ cwd
138
+ })
139
+ );
140
+ };
134
141
  });
135
142
  }
136
143
  function getCssTasks() {
@@ -140,11 +147,13 @@ function getTasks(options) {
140
147
  return extensions[assetType].map((x) => {
141
148
  const src = `${base}**/*.${x}`;
142
149
  globsSetAdd(src);
143
- return () => gulp.src([src, ...globs], { cwd }).pipe(transformWxss()).pipe(
144
- gulp.dest(outDir, {
145
- cwd
146
- })
147
- );
150
+ return function CssTask() {
151
+ return gulp.src([src, ...globs], { cwd, since: gulp.lastRun(CssTask) }).pipe(plumber()).pipe(gulpif(Boolean(postcssOptions), postcssrc(postcssOptions?.plugins, postcssOptions?.options))).pipe(transformWxss()).pipe(
152
+ gulp.dest(outDir, {
153
+ cwd
154
+ })
155
+ );
156
+ };
148
157
  });
149
158
  }
150
159
  function getHtmlTasks() {
@@ -154,11 +163,13 @@ function getTasks(options) {
154
163
  return extensions[assetType].map((x) => {
155
164
  const src = `${base}**/*.${x}`;
156
165
  globsSetAdd(src);
157
- return () => gulp.src([src, ...globs], { cwd }).pipe(transformWxml()).pipe(
158
- gulp.dest(outDir, {
159
- cwd
160
- })
161
- );
166
+ return function HtmlTask() {
167
+ return gulp.src([src, ...globs], { cwd, since: gulp.lastRun(HtmlTask) }).pipe(plumber()).pipe(transformWxml()).pipe(
168
+ gulp.dest(outDir, {
169
+ cwd
170
+ })
171
+ );
172
+ };
162
173
  });
163
174
  }
164
175
  function copyOthers() {
@@ -167,7 +178,7 @@ function getTasks(options) {
167
178
  return `${base}${x}`;
168
179
  });
169
180
  globsSetAdd(globs);
170
- return gulp.src(globs, { cwd }).pipe(
181
+ return gulp.src(globs, { cwd, since: gulp.lastRun(copyOthers) }).pipe(plumber()).pipe(
171
182
  gulp.dest(outDir, {
172
183
  cwd
173
184
  })
@@ -207,7 +218,8 @@ function createBuilder(options) {
207
218
  extensions,
208
219
  exclude,
209
220
  include,
210
- watchOptions
221
+ watchOptions,
222
+ postcssOptions
211
223
  } = defu(options, {
212
224
  outDir: "dist",
213
225
  weappTailwindcssOptions: {},
@@ -219,6 +231,9 @@ function createBuilder(options) {
219
231
  html: ["wxml"],
220
232
  css: ["wxss", "less", "sass", "scss"],
221
233
  json: ["json"]
234
+ },
235
+ watchOptions: {
236
+ events: ["add", "change", "unlink", "ready"]
222
237
  }
223
238
  });
224
239
  const { copyOthers, getCssTasks, getHtmlTasks, getJsTasks, getJsonTasks, globsSet } = getTasks({
@@ -230,7 +245,8 @@ function createBuilder(options) {
230
245
  extensions,
231
246
  exclude,
232
247
  include,
233
- watchOptions
248
+ watchOptions,
249
+ postcssOptions
234
250
  });
235
251
  const tasks = [...getJsTasks(), ...getJsonTasks(), ...getCssTasks(), ...getHtmlTasks(), copyOthers];
236
252
  async function runTasks() {
@@ -272,19 +288,32 @@ function createBuilder(options) {
272
288
  watcher.on("unlink", function(path2) {
273
289
  console.log(`File ${path2} was removed`);
274
290
  });
291
+ watcher.on("ready", function() {
292
+ console.log(`Weapp-tailwindcss is Ready!`);
293
+ });
275
294
  this.watcher = watcher;
276
295
  return this;
277
296
  },
278
297
  globsSet
279
298
  };
280
299
  }
281
- function build(options) {
282
- const builder = createBuilder(options);
283
- return builder.build();
300
+ async function build(options) {
301
+ let postcssOptions;
302
+ try {
303
+ postcssOptions = await loadPostcssConfig({ cwd: options?.root });
304
+ } catch {
305
+ }
306
+ const builder = createBuilder(defu(options, { postcssOptions }));
307
+ return await builder.build();
284
308
  }
285
- function watch(options) {
286
- const builder = createBuilder(options);
287
- return builder.watch();
309
+ async function watch(options) {
310
+ let postcssOptions;
311
+ try {
312
+ postcssOptions = await loadPostcssConfig({ cwd: options?.root });
313
+ } catch {
314
+ }
315
+ const builder = createBuilder(defu(options, { postcssOptions }));
316
+ return await builder.watch();
288
317
  }
289
318
 
290
319
  function getDefaultExportFromCjs (x) {
@@ -750,28 +779,16 @@ function createCli() {
750
779
  const configLoader = createConfigLoader(cwd);
751
780
  const userDefinedConfig = configLoader.search(cwd);
752
781
  program.command("dev").alias("serve").action(async () => {
753
- const postcssOptions = await loadPostcssConfig({
754
- cwd
755
- });
756
782
  await watch(
757
783
  defu(userDefinedConfig?.config, {
758
- root: cwd,
759
- weappTailwindcssOptions: {
760
- postcssOptions
761
- }
784
+ root: cwd
762
785
  })
763
786
  );
764
787
  });
765
788
  program.command("build").action(async () => {
766
- const postcssOptions = await loadPostcssConfig({
767
- cwd
768
- });
769
789
  await build(
770
790
  defu(userDefinedConfig?.config, {
771
- root: cwd,
772
- weappTailwindcssOptions: {
773
- postcssOptions
774
- }
791
+ root: cwd
775
792
  })
776
793
  );
777
794
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/cli",
3
- "version": "0.0.0-alpha.3",
3
+ "version": "0.0.0-alpha.5",
4
4
  "description": "The cli of weapp-tailwindcss",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -27,15 +27,22 @@
27
27
  "fs-extra": "^11.2.0",
28
28
  "gulp": "^5.0.0",
29
29
  "gulp-less": "^5.0.0",
30
+ "gulp-plumber": "^1.2.1",
31
+ "gulp-postcss": "^10.0.0",
30
32
  "gulp-sass": "^5.1.0",
33
+ "gulp-if": "^3.0.0",
34
+ "postcss": "^8.4.38",
31
35
  "postcss-load-config": "^5.0.3",
32
- "weapp-tailwindcss": "3.2.0-alpha.3"
36
+ "weapp-tailwindcss": "3.2.0-alpha.4"
33
37
  },
34
38
  "devDependencies": {
35
39
  "@types/fs-extra": "^11.0.4",
36
40
  "@types/get-value": "^3.0.5",
37
41
  "@types/gulp": "^4.0.17",
42
+ "@types/gulp-if": "^3.0.4",
38
43
  "@types/gulp-less": "^0.0.36",
44
+ "@types/gulp-plumber": "^0.0.37",
45
+ "@types/gulp-postcss": "^8.0.6",
39
46
  "@types/gulp-sass": "^5.0.4",
40
47
  "@types/set-value": "^4.0.3",
41
48
  "@types/vinyl-fs": "^3.0.5",