@weapp-tailwindcss/init 2.0.2 → 2.0.4

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,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -20,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  let node_process = require("node:process");
25
24
  node_process = __toESM(node_process, 1);
26
25
  let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
@@ -31,7 +30,7 @@ let pathe = require("pathe");
31
30
  pathe = __toESM(pathe, 1);
32
31
  let semver = require("semver");
33
32
  semver = __toESM(semver, 1);
34
- //#region src/npm.ts
33
+ // src/npm.ts
35
34
  /**
36
35
  * @example 'https://registry.npmjs.org'
37
36
  * @example 'https://registry.npmmirror.com'
@@ -66,8 +65,7 @@ async function getDevDepsVersions(options, mode = "v4") {
66
65
  return [x[0], `^${await getLatestVersionInRange(...x, options)}`];
67
66
  })));
68
67
  }
69
- //#endregion
70
- //#region src/index.ts
68
+ // src/index.ts
71
69
  async function createContext(options) {
72
70
  const { cwd, pkgJsonBasename, postcssConfigBasename, tailwindConfigBasename, cssEntryBasename, sourceGlob, mode, fetchOptions } = options;
73
71
  const pkgJsonPath = pathe.default.resolve(cwd, pkgJsonBasename);
@@ -158,7 +156,6 @@ async function init(options) {
158
156
  _weapp_tailwindcss_logger.logger.success("`weapp-tailwindcss` v5 初始化完成!请将 WeappTailwindcss() 注册到项目构建器,并确认入口 CSS 被实际引入。");
159
157
  }
160
158
  }
161
- //#endregion
162
159
  exports.createContext = createContext;
163
160
  exports.getInitDefaults = getInitDefaults;
164
161
  exports.init = init;
@@ -0,0 +1,343 @@
1
+ import { Options } from "npm-registry-fetch";
2
+ interface PackageJson {
3
+ /**
4
+ * The name is what your thing is called.
5
+ * Some rules:
6
+ * - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
7
+ * - The name can’t start with a dot or an underscore.
8
+ * - New packages must not have uppercase letters in the name.
9
+ * - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
10
+ */
11
+ name?: string;
12
+ /**
13
+ * Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
14
+ */
15
+ version?: string;
16
+ /**
17
+ * Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
18
+ */
19
+ description?: string;
20
+ /**
21
+ * Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
22
+ */
23
+ keywords?: string[];
24
+ /**
25
+ * The url to the project homepage.
26
+ */
27
+ homepage?: string;
28
+ /**
29
+ * The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
30
+ */
31
+ bugs?: string | {
32
+ url?: string;
33
+ email?: string;
34
+ };
35
+ /**
36
+ * You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
37
+ */
38
+ license?: string;
39
+ /**
40
+ * Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
41
+ * For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
42
+ */
43
+ repository?: string | {
44
+ type: string;
45
+ url: string;
46
+ /**
47
+ * If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
48
+ */
49
+ directory?: string;
50
+ };
51
+ /**
52
+ * The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
53
+ */
54
+ scripts?: PackageJsonScripts;
55
+ /**
56
+ * If you set `"private": true` in your package.json, then npm will refuse to publish it.
57
+ */
58
+ private?: boolean;
59
+ /**
60
+ * The “author” is one person.
61
+ */
62
+ author?: PackageJsonPerson;
63
+ /**
64
+ * “contributors” is an array of people.
65
+ */
66
+ contributors?: PackageJsonPerson[];
67
+ /**
68
+ * An object containing a URL that provides up-to-date information
69
+ * about ways to help fund development of your package,
70
+ * a string URL, or an array of objects and string URLs
71
+ */
72
+ funding?: PackageJsonFunding | PackageJsonFunding[];
73
+ /**
74
+ * The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
75
+ */
76
+ files?: string[];
77
+ /**
78
+ * The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
79
+ * This should be a module ID relative to the root of your package folder.
80
+ * For most modules, it makes the most sense to have a main script and often not much else.
81
+ */
82
+ main?: string;
83
+ /**
84
+ * If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
85
+ */
86
+ browser?: string | Record<string, string | false>;
87
+ /**
88
+ * The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
89
+ */
90
+ unpkg?: string;
91
+ /**
92
+ * A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
93
+ */
94
+ bin?: string | Record<string, string>;
95
+ /**
96
+ * Specify either a single file or an array of filenames to put in place for the `man` program to find.
97
+ */
98
+ man?: string | string[];
99
+ /**
100
+ * Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
101
+ */
102
+ dependencies?: Record<string, string>;
103
+ /**
104
+ * If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
105
+ * In this case, it’s best to map these additional items in a `devDependencies` object.
106
+ */
107
+ devDependencies?: Record<string, string>;
108
+ /**
109
+ * If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
110
+ */
111
+ optionalDependencies?: Record<string, string>;
112
+ /**
113
+ * In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
114
+ */
115
+ peerDependencies?: Record<string, string>;
116
+ /**
117
+ * TypeScript typings, typically ending by `.d.ts`.
118
+ */
119
+ types?: string;
120
+ /**
121
+ * This field is synonymous with `types`.
122
+ */
123
+ typings?: string;
124
+ /**
125
+ * Non-Standard Node.js alternate entry-point to main.
126
+ * An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
127
+ */
128
+ module?: string;
129
+ /**
130
+ * Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
131
+ *
132
+ * Docs:
133
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
134
+ *
135
+ * @default 'commonjs'
136
+ * @since Node.js v14
137
+ */
138
+ type?: "module" | "commonjs";
139
+ /**
140
+ * Alternate and extensible alternative to "main" entry point.
141
+ *
142
+ * When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
143
+ *
144
+ * Docs:
145
+ * - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
146
+ *
147
+ * @since Node.js v12.7
148
+ */
149
+ exports?: PackageJsonExports;
150
+ /**
151
+ * Docs:
152
+ * - https://nodejs.org/api/packages.html#imports
153
+ */
154
+ imports?: Record<string, string | Record<string, string>>;
155
+ /**
156
+ * The field is used to define a set of sub-packages (or workspaces) within a monorepo.
157
+ *
158
+ * This field is an array of glob patterns or an object with specific configurations for managing
159
+ * multiple packages in a single repository.
160
+ */
161
+ workspaces?: string[] | {
162
+ /**
163
+ * Workspace package paths. Glob patterns are supported.
164
+ */
165
+ packages?: string[];
166
+ /**
167
+ * Packages to block from hoisting to the workspace root.
168
+ * Uses glob patterns to match module paths in the dependency tree.
169
+ *
170
+ * Docs:
171
+ * - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
172
+ */
173
+ nohoist?: string[];
174
+ };
175
+ /**
176
+ * The field is used to specify different TypeScript declaration files for
177
+ * different versions of TypeScript, allowing for version-specific type definitions.
178
+ */
179
+ typesVersions?: Record<string, Record<string, string[]>>;
180
+ /**
181
+ * You can specify which operating systems your module will run on:
182
+ * ```json
183
+ * {
184
+ * "os": ["darwin", "linux"]
185
+ * }
186
+ * ```
187
+ * You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
188
+ * ```json
189
+ * {
190
+ * "os": ["!win32"]
191
+ * }
192
+ * ```
193
+ * The host operating system is determined by `process.platform`
194
+ * It is allowed to both block and allow an item, although there isn't any good reason to do this.
195
+ */
196
+ os?: string[];
197
+ /**
198
+ * If your code only runs on certain cpu architectures, you can specify which ones.
199
+ * ```json
200
+ * {
201
+ * "cpu": ["x64", "ia32"]
202
+ * }
203
+ * ```
204
+ * Like the `os` option, you can also block architectures:
205
+ * ```json
206
+ * {
207
+ * "cpu": ["!arm", "!mips"]
208
+ * }
209
+ * ```
210
+ * The host architecture is determined by `process.arch`
211
+ */
212
+ cpu?: string[];
213
+ /**
214
+ * This is a set of config values that will be used at publish-time.
215
+ */
216
+ publishConfig?: {
217
+ /**
218
+ * The registry that will be used if the package is published.
219
+ */
220
+ registry?: string;
221
+ /**
222
+ * The tag that will be used if the package is published.
223
+ */
224
+ tag?: string;
225
+ /**
226
+ * The access level that will be used if the package is published.
227
+ */
228
+ access?: "public" | "restricted";
229
+ /**
230
+ * **pnpm-only**
231
+ *
232
+ * By default, for portability reasons, no files except those listed in
233
+ * the bin field will be marked as executable in the resulting package
234
+ * archive. The executableFiles field lets you declare additional fields
235
+ * that must have the executable flag (+x) set even if
236
+ * they aren't directly accessible through the bin field.
237
+ */
238
+ executableFiles?: string[];
239
+ /**
240
+ * **pnpm-only**
241
+ *
242
+ * You also can use the field `publishConfig.directory` to customize
243
+ * the published subdirectory relative to the current `package.json`.
244
+ *
245
+ * It is expected to have a modified version of the current package in
246
+ * the specified directory (usually using third party build tools).
247
+ */
248
+ directory?: string;
249
+ /**
250
+ * **pnpm-only**
251
+ *
252
+ * When set to `true`, the project will be symlinked from the
253
+ * `publishConfig.directory` location during local development.
254
+ * @default true
255
+ */
256
+ linkDirectory?: boolean;
257
+ } & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
258
+ /**
259
+ * See: https://nodejs.org/api/packages.html#packagemanager
260
+ * This field defines which package manager is expected to be used when working on the current project.
261
+ * Should be of the format: `<name>@<version>[#hash]`
262
+ */
263
+ packageManager?: string;
264
+ [key: string]: any;
265
+ }
266
+ /**
267
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
268
+ */
269
+ type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
270
+ /**
271
+ * See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
272
+ */
273
+ type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
274
+ /**
275
+ * See: https://pnpm.io/scripts#lifecycle-scripts
276
+ */
277
+ type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
278
+ type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
279
+ type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
280
+ type PackageJsonScripts = { [P in PackageJsonScriptName]?: string; };
281
+ /**
282
+ * A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
283
+ */
284
+ type PackageJsonPerson = string | {
285
+ name: string;
286
+ email?: string;
287
+ url?: string;
288
+ };
289
+ type PackageJsonFunding = string | {
290
+ url: string;
291
+ type?: string;
292
+ };
293
+ type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
294
+ type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>; };
295
+ type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
296
+ type FetchOptions = Options;
297
+ type InitMode = 'v4' | 'legacy';
298
+ export interface CreateContextOptions {
299
+ cwd: string;
300
+ pkgJsonBasename?: string;
301
+ postcssConfigBasename?: string;
302
+ tailwindConfigBasename?: string;
303
+ cssEntryBasename?: string;
304
+ sourceGlob?: string;
305
+ mode?: InitMode;
306
+ fetchOptions?: FetchOptions;
307
+ }
308
+ export declare function createContext(options: Required<CreateContextOptions>): Promise<{
309
+ pkgJson: PackageJson;
310
+ pkgJsonPath: string;
311
+ cwd: string;
312
+ versions: {
313
+ tailwindcss: string;
314
+ 'weapp-tailwindcss': string;
315
+ } | {
316
+ tailwindcss: string;
317
+ postcss: string;
318
+ autoprefixer: string;
319
+ 'weapp-tailwindcss': string;
320
+ };
321
+ postcssConfigBasename: string;
322
+ tailwindConfigBasename: string;
323
+ cssEntryBasename: string;
324
+ sourceGlob: string;
325
+ mode: InitMode;
326
+ readonly type: "module" | "commonjs" | undefined;
327
+ } | undefined>;
328
+ export type Context = Exclude<Awaited<ReturnType<typeof createContext>>, undefined>;
329
+ export declare function updatePackageJson(ctx: Context): Promise<void>;
330
+ export declare function touchPostcssConfig(ctx: Context): Promise<boolean>;
331
+ export declare function touchTailwindConfig(ctx: Context): Promise<boolean>;
332
+ export declare function touchCssEntry(ctx: Context): Promise<boolean>;
333
+ export declare function getInitDefaults(): {
334
+ cwd: string;
335
+ postcssConfigBasename: string;
336
+ tailwindConfigBasename: string;
337
+ cssEntryBasename: string;
338
+ sourceGlob: string;
339
+ pkgJsonBasename: string;
340
+ mode: InitMode;
341
+ };
342
+ export declare function init(options?: CreateContextOptions): Promise<void>;
343
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Options } from "npm-registry-fetch";
2
- //#region ../../node_modules/.pnpm/pkg-types@2.3.3/node_modules/pkg-types/dist/index.d.mts
3
2
  interface PackageJson {
4
3
  /**
5
4
  * The name is what your thing is called.
@@ -294,12 +293,8 @@ type PackageJsonFunding = string | {
294
293
  type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
295
294
  type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>; };
296
295
  type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
297
- //#endregion
298
- //#region src/npm.d.ts
299
296
  type FetchOptions = Options;
300
297
  type InitMode = 'v4' | 'legacy';
301
- //#endregion
302
- //#region src/index.d.ts
303
298
  export interface CreateContextOptions {
304
299
  cwd: string;
305
300
  pkgJsonBasename?: string;
@@ -345,4 +340,4 @@ export declare function getInitDefaults(): {
345
340
  mode: InitMode;
346
341
  };
347
342
  export declare function init(options?: CreateContextOptions): Promise<void>;
348
- //#endregion
343
+ export {};
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { defu, setValue } from "@weapp-tailwindcss/shared";
4
4
  import fs from "fs-extra";
5
5
  import path from "pathe";
6
6
  import semver from "semver";
7
- //#region src/npm.ts
7
+ // src/npm.ts
8
8
  /**
9
9
  * @example 'https://registry.npmjs.org'
10
10
  * @example 'https://registry.npmmirror.com'
@@ -39,8 +39,7 @@ async function getDevDepsVersions(options, mode = "v4") {
39
39
  return [x[0], `^${await getLatestVersionInRange(...x, options)}`];
40
40
  })));
41
41
  }
42
- //#endregion
43
- //#region src/index.ts
42
+ // src/index.ts
44
43
  async function createContext(options) {
45
44
  const { cwd, pkgJsonBasename, postcssConfigBasename, tailwindConfigBasename, cssEntryBasename, sourceGlob, mode, fetchOptions } = options;
46
45
  const pkgJsonPath = path.resolve(cwd, pkgJsonBasename);
@@ -131,5 +130,4 @@ async function init(options) {
131
130
  logger.success("`weapp-tailwindcss` v5 初始化完成!请将 WeappTailwindcss() 注册到项目构建器,并确认入口 CSS 被实际引入。");
132
131
  }
133
132
  }
134
- //#endregion
135
133
  export { createContext, getInitDefaults, init, touchCssEntry, touchPostcssConfig, touchTailwindConfig, updatePackageJson };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/init",
3
3
  "type": "module",
4
- "version": "2.0.2",
4
+ "version": "2.0.4",
5
5
  "description": "Project initializer for cross-platform Tailwind CSS with weapp-tailwindcss. 用于初始化跨端 Tailwind CSS 项目的 weapp-tailwindcss 工具。",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -18,9 +18,14 @@
18
18
  "sideEffects": false,
19
19
  "exports": {
20
20
  ".": {
21
- "types": "./dist/index.d.ts",
22
- "import": "./dist/index.js",
23
- "require": "./dist/index.cjs"
21
+ "import": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
24
29
  }
25
30
  },
26
31
  "main": "./dist/index.cjs",
@@ -33,12 +38,13 @@
33
38
  "node": "^20.19.0 || >=22.12.0"
34
39
  },
35
40
  "dependencies": {
36
- "@weapp-tailwindcss/logger": "2.0.4",
37
- "@weapp-tailwindcss/shared": "2.0.4",
41
+ "@types/npm-registry-fetch": "^8.0.9",
42
+ "@weapp-tailwindcss/logger": "2.0.5",
43
+ "@weapp-tailwindcss/shared": "2.0.5",
38
44
  "fs-extra": "^11.4.1",
39
45
  "npm-registry-fetch": "^20.0.1",
40
46
  "pathe": "^2.0.3",
41
- "semver": "~7.8.5"
47
+ "semver": "~7.8.6"
42
48
  },
43
49
  "scripts": {
44
50
  "dev": "tsdown --watch --sourcemap",