@weapp-tailwindcss/init 2.0.1 → 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 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
@@ -17,3 +17,5 @@ await init({ cwd: process.cwd() })
17
17
  ## 官网
18
18
 
19
19
  更多接入方式、配置说明和框架示例见 [weapp-tailwindcss 官方文档](https://tw.weapp.dev)。
20
+
21
+ 依赖版本按目标主版本范围选择最高稳定版,不依赖 registry 返回顺序。没有匹配稳定版时,初始化会在写入项目文件前报错,不回退到其他主版本或预发布版。
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
- return Object.keys(response.versions).filter((version) => version.startsWith(versionRange)).at(-1) ?? response["dist-tags"].latest;
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.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
- return Object.keys(response.versions).filter((version) => version.startsWith(versionRange)).at(-1) ?? response["dist-tags"].latest;
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.1",
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/sonofmagic/weapp-tailwindcss.git",
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/sonofmagic/weapp-tailwindcss/issues"
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.3",
37
- "@weapp-tailwindcss/shared": "2.0.3",
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.5"
41
42
  },
42
43
  "scripts": {
43
44
  "dev": "tsdown --watch --sourcemap",