@weapp-tailwindcss/init 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/index.cjs +7 -1
- package/dist/index.d.ts +11 -14
- package/dist/index.js +6 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -11,3 +11,5 @@ Use `mode: 'legacy'` explicitly when maintaining a Tailwind 3 project that still
|
|
|
11
11
|
## Website
|
|
12
12
|
|
|
13
13
|
For setup guides, configuration references, and framework examples, see the [official weapp-tailwindcss documentation](https://tw.weapp.dev).
|
|
14
|
+
|
|
15
|
+
Dependency versions are selected as the highest stable versions within the requested major ranges, regardless of registry response order. If no stable version matches, initialization fails before writing project files; it does not fall back to another major version or a prerelease.
|
package/README.zh-CN.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -29,6 +29,8 @@ let fs_extra = require("fs-extra");
|
|
|
29
29
|
fs_extra = __toESM(fs_extra, 1);
|
|
30
30
|
let pathe = require("pathe");
|
|
31
31
|
pathe = __toESM(pathe, 1);
|
|
32
|
+
let semver = require("semver");
|
|
33
|
+
semver = __toESM(semver, 1);
|
|
32
34
|
//#region src/npm.ts
|
|
33
35
|
/**
|
|
34
36
|
* @example 'https://registry.npmjs.org'
|
|
@@ -41,8 +43,12 @@ function fetchPackage(packageName, options) {
|
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
async function getLatestVersionInRange(packageName, versionRange, options) {
|
|
46
|
+
if (!semver.default.validRange(versionRange)) throw new Error(`Invalid version range for ${packageName}: ${versionRange}`);
|
|
44
47
|
const response = await fetchPackage(packageName, options);
|
|
45
|
-
|
|
48
|
+
const versions = Object.keys(response.versions).filter((version) => semver.default.valid(version) && !semver.default.prerelease(version));
|
|
49
|
+
const version = semver.default.maxSatisfying(versions, versionRange);
|
|
50
|
+
if (!version) throw new Error(`No stable version of ${packageName} satisfies ${versionRange}`);
|
|
51
|
+
return version;
|
|
46
52
|
}
|
|
47
53
|
const defaultDevDeps = {
|
|
48
54
|
"tailwindcss": "4",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Options } from "npm-registry-fetch";
|
|
2
|
-
//#region ../../node_modules/.pnpm/pkg-types@2.3.
|
|
3
|
-
//#endregion
|
|
4
|
-
//#region src/packagejson/types.d.ts
|
|
2
|
+
//#region ../../node_modules/.pnpm/pkg-types@2.3.3/node_modules/pkg-types/dist/index.d.mts
|
|
5
3
|
interface PackageJson {
|
|
6
4
|
/**
|
|
7
5
|
* The name is what your thing is called.
|
|
@@ -302,7 +300,7 @@ type FetchOptions = Options;
|
|
|
302
300
|
type InitMode = 'v4' | 'legacy';
|
|
303
301
|
//#endregion
|
|
304
302
|
//#region src/index.d.ts
|
|
305
|
-
interface CreateContextOptions {
|
|
303
|
+
export interface CreateContextOptions {
|
|
306
304
|
cwd: string;
|
|
307
305
|
pkgJsonBasename?: string;
|
|
308
306
|
postcssConfigBasename?: string;
|
|
@@ -312,7 +310,7 @@ interface CreateContextOptions {
|
|
|
312
310
|
mode?: InitMode;
|
|
313
311
|
fetchOptions?: FetchOptions;
|
|
314
312
|
}
|
|
315
|
-
declare function createContext(options: Required<CreateContextOptions>): Promise<{
|
|
313
|
+
export declare function createContext(options: Required<CreateContextOptions>): Promise<{
|
|
316
314
|
pkgJson: PackageJson;
|
|
317
315
|
pkgJsonPath: string;
|
|
318
316
|
cwd: string;
|
|
@@ -332,12 +330,12 @@ declare function createContext(options: Required<CreateContextOptions>): Promise
|
|
|
332
330
|
mode: InitMode;
|
|
333
331
|
readonly type: "module" | "commonjs" | undefined;
|
|
334
332
|
} | undefined>;
|
|
335
|
-
type Context = Exclude<Awaited<ReturnType<typeof createContext>>, undefined>;
|
|
336
|
-
declare function updatePackageJson(ctx: Context): Promise<void>;
|
|
337
|
-
declare function touchPostcssConfig(ctx: Context): Promise<boolean>;
|
|
338
|
-
declare function touchTailwindConfig(ctx: Context): Promise<boolean>;
|
|
339
|
-
declare function touchCssEntry(ctx: Context): Promise<boolean>;
|
|
340
|
-
declare function getInitDefaults(): {
|
|
333
|
+
export type Context = Exclude<Awaited<ReturnType<typeof createContext>>, undefined>;
|
|
334
|
+
export declare function updatePackageJson(ctx: Context): Promise<void>;
|
|
335
|
+
export declare function touchPostcssConfig(ctx: Context): Promise<boolean>;
|
|
336
|
+
export declare function touchTailwindConfig(ctx: Context): Promise<boolean>;
|
|
337
|
+
export declare function touchCssEntry(ctx: Context): Promise<boolean>;
|
|
338
|
+
export declare function getInitDefaults(): {
|
|
341
339
|
cwd: string;
|
|
342
340
|
postcssConfigBasename: string;
|
|
343
341
|
tailwindConfigBasename: string;
|
|
@@ -346,6 +344,5 @@ declare function getInitDefaults(): {
|
|
|
346
344
|
pkgJsonBasename: string;
|
|
347
345
|
mode: InitMode;
|
|
348
346
|
};
|
|
349
|
-
declare function init(options?: CreateContextOptions): Promise<void>;
|
|
350
|
-
//#endregion
|
|
351
|
-
export { Context, CreateContextOptions, createContext, getInitDefaults, init, touchCssEntry, touchPostcssConfig, touchTailwindConfig, updatePackageJson };
|
|
347
|
+
export declare function init(options?: CreateContextOptions): Promise<void>;
|
|
348
|
+
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { logger } from "@weapp-tailwindcss/logger";
|
|
|
3
3
|
import { defu, setValue } from "@weapp-tailwindcss/shared";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
5
|
import path from "pathe";
|
|
6
|
+
import semver from "semver";
|
|
6
7
|
//#region src/npm.ts
|
|
7
8
|
/**
|
|
8
9
|
* @example 'https://registry.npmjs.org'
|
|
@@ -15,8 +16,12 @@ function fetchPackage(packageName, options) {
|
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
async function getLatestVersionInRange(packageName, versionRange, options) {
|
|
19
|
+
if (!semver.validRange(versionRange)) throw new Error(`Invalid version range for ${packageName}: ${versionRange}`);
|
|
18
20
|
const response = await fetchPackage(packageName, options);
|
|
19
|
-
|
|
21
|
+
const versions = Object.keys(response.versions).filter((version) => semver.valid(version) && !semver.prerelease(version));
|
|
22
|
+
const version = semver.maxSatisfying(versions, versionRange);
|
|
23
|
+
if (!version) throw new Error(`No stable version of ${packageName} satisfies ${versionRange}`);
|
|
24
|
+
return version;
|
|
20
25
|
}
|
|
21
26
|
const defaultDevDeps = {
|
|
22
27
|
"tailwindcss": "4",
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.2",
|
|
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",
|
|
8
8
|
"homepage": "https://tw.weapp.dev/docs/quick-start/install",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/
|
|
11
|
+
"url": "git+https://github.com/weapp-tailwindcss/weapp-tailwindcss.git",
|
|
12
12
|
"directory": "packages/init"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/
|
|
15
|
+
"url": "https://github.com/weapp-tailwindcss/weapp-tailwindcss/issues"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [],
|
|
18
18
|
"sideEffects": false,
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
"node": "^20.19.0 || >=22.12.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@weapp-tailwindcss/logger": "2.0.
|
|
37
|
-
"@weapp-tailwindcss/shared": "2.0.
|
|
38
|
-
"fs-extra": "^11.4.
|
|
36
|
+
"@weapp-tailwindcss/logger": "2.0.4",
|
|
37
|
+
"@weapp-tailwindcss/shared": "2.0.4",
|
|
38
|
+
"fs-extra": "^11.4.1",
|
|
39
39
|
"npm-registry-fetch": "^20.0.1",
|
|
40
|
-
"pathe": "^2.0.3"
|
|
40
|
+
"pathe": "^2.0.3",
|
|
41
|
+
"semver": "~7.8.5"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"dev": "tsdown --watch --sourcemap",
|