@weapp-tailwindcss/init 2.0.1 → 2.0.3
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 +10 -7
- package/dist/index.d.ts +1 -6
- package/dist/index.js +8 -5
- package/package.json +7 -6
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
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");
|
|
@@ -29,7 +28,9 @@ let fs_extra = require("fs-extra");
|
|
|
29
28
|
fs_extra = __toESM(fs_extra, 1);
|
|
30
29
|
let pathe = require("pathe");
|
|
31
30
|
pathe = __toESM(pathe, 1);
|
|
32
|
-
|
|
31
|
+
let semver = require("semver");
|
|
32
|
+
semver = __toESM(semver, 1);
|
|
33
|
+
// src/npm.ts
|
|
33
34
|
/**
|
|
34
35
|
* @example 'https://registry.npmjs.org'
|
|
35
36
|
* @example 'https://registry.npmmirror.com'
|
|
@@ -41,8 +42,12 @@ function fetchPackage(packageName, options) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
async function getLatestVersionInRange(packageName, versionRange, options) {
|
|
45
|
+
if (!semver.default.validRange(versionRange)) throw new Error(`Invalid version range for ${packageName}: ${versionRange}`);
|
|
44
46
|
const response = await fetchPackage(packageName, options);
|
|
45
|
-
|
|
47
|
+
const versions = Object.keys(response.versions).filter((version) => semver.default.valid(version) && !semver.default.prerelease(version));
|
|
48
|
+
const version = semver.default.maxSatisfying(versions, versionRange);
|
|
49
|
+
if (!version) throw new Error(`No stable version of ${packageName} satisfies ${versionRange}`);
|
|
50
|
+
return version;
|
|
46
51
|
}
|
|
47
52
|
const defaultDevDeps = {
|
|
48
53
|
"tailwindcss": "4",
|
|
@@ -60,8 +65,7 @@ async function getDevDepsVersions(options, mode = "v4") {
|
|
|
60
65
|
return [x[0], `^${await getLatestVersionInRange(...x, options)}`];
|
|
61
66
|
})));
|
|
62
67
|
}
|
|
63
|
-
|
|
64
|
-
//#region src/index.ts
|
|
68
|
+
// src/index.ts
|
|
65
69
|
async function createContext(options) {
|
|
66
70
|
const { cwd, pkgJsonBasename, postcssConfigBasename, tailwindConfigBasename, cssEntryBasename, sourceGlob, mode, fetchOptions } = options;
|
|
67
71
|
const pkgJsonPath = pathe.default.resolve(cwd, pkgJsonBasename);
|
|
@@ -152,7 +156,6 @@ async function init(options) {
|
|
|
152
156
|
_weapp_tailwindcss_logger.logger.success("`weapp-tailwindcss` v5 初始化完成!请将 WeappTailwindcss() 注册到项目构建器,并确认入口 CSS 被实际引入。");
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
|
-
//#endregion
|
|
156
159
|
exports.createContext = createContext;
|
|
157
160
|
exports.getInitDefaults = getInitDefaults;
|
|
158
161
|
exports.init = init;
|
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
|
-
|
|
343
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ 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
|
-
|
|
6
|
+
import semver from "semver";
|
|
7
|
+
// src/npm.ts
|
|
7
8
|
/**
|
|
8
9
|
* @example 'https://registry.npmjs.org'
|
|
9
10
|
* @example 'https://registry.npmmirror.com'
|
|
@@ -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",
|
|
@@ -34,8 +39,7 @@ async function getDevDepsVersions(options, mode = "v4") {
|
|
|
34
39
|
return [x[0], `^${await getLatestVersionInRange(...x, options)}`];
|
|
35
40
|
})));
|
|
36
41
|
}
|
|
37
|
-
|
|
38
|
-
//#region src/index.ts
|
|
42
|
+
// src/index.ts
|
|
39
43
|
async function createContext(options) {
|
|
40
44
|
const { cwd, pkgJsonBasename, postcssConfigBasename, tailwindConfigBasename, cssEntryBasename, sourceGlob, mode, fetchOptions } = options;
|
|
41
45
|
const pkgJsonPath = path.resolve(cwd, pkgJsonBasename);
|
|
@@ -126,5 +130,4 @@ async function init(options) {
|
|
|
126
130
|
logger.success("`weapp-tailwindcss` v5 初始化完成!请将 WeappTailwindcss() 注册到项目构建器,并确认入口 CSS 被实际引入。");
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
|
-
//#endregion
|
|
130
133
|
export { createContext, getInitDefaults, init, touchCssEntry, touchPostcssConfig, touchTailwindConfig, updatePackageJson };
|
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.3",
|
|
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.
|
|
36
|
+
"@weapp-tailwindcss/logger": "2.0.4",
|
|
37
|
+
"@weapp-tailwindcss/shared": "2.0.4",
|
|
38
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.6"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"dev": "tsdown --watch --sourcemap",
|