@heycar/heycars-map 0.9.7 → 0.9.8

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.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import { open } from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ import * as process from "node:process";
5
+ import { fileURLToPath } from "node:url";
6
+ import * as semver from "semver";
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const libPackagePath = path.resolve(__dirname, "../package.json");
9
+ const projectPackagePath = path.resolve(process.cwd(), "package.json");
10
+ const readProjectPackage = async (packagePath) => {
11
+ let fileHandler;
12
+ try {
13
+ fileHandler = await open(packagePath);
14
+ } catch (err) {
15
+ if (err.code == "ENOENT") throw new Error("hint: 确保在项目根目录下运行");
16
+ else throw err;
17
+ }
18
+ try {
19
+ const content = await fileHandler.readFile("utf-8");
20
+ return JSON.parse(content);
21
+ } finally {
22
+ fileHandler.close();
23
+ }
24
+ };
25
+ const checkVersion = async (projectPackagePath, libPackagePath) => {
26
+ const { dependencies } = await readProjectPackage(projectPackagePath);
27
+ const pkg = await readProjectPackage(libPackagePath);
28
+ const range = dependencies?.[pkg.name];
29
+ if (range.startsWith("file:///")) return;
30
+ if (!range) throw new Error(`hint: 在 package.json 的 dependencies 下面没有 ${pkg.name}`);
31
+ if (!semver.satisfies(pkg.version, range))
32
+ throw new Error(
33
+ `hint: ${pkg.name} 版本不匹配, 要求的版本是: ${range}, 实际安装的版本是 ${pkg.version}`,
34
+ );
35
+ };
36
+ checkVersion(projectPackagePath, libPackagePath);
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { FileHandle, open } from "node:fs/promises";
4
+ import * as path from "node:path";
5
+ import * as process from "node:process";
6
+ import { fileURLToPath } from "node:url";
7
+ import * as semver from "semver";
8
+
9
+ interface Package {
10
+ name?: string;
11
+ version?: string;
12
+ dependencies?: Record<string, string>;
13
+ }
14
+
15
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
16
+ const libPackagePath = path.resolve(__dirname, "../package.json");
17
+ const projectPackagePath = path.resolve(process.cwd(), "package.json");
18
+
19
+ const readProjectPackage = async (packagePath: string): Promise<Package> => {
20
+ let fileHandler: FileHandle;
21
+ try {
22
+ fileHandler = await open(packagePath);
23
+ } catch (err) {
24
+ if (err.code == "ENOENT") throw new Error("hint: 确保在项目根目录下运行");
25
+ else throw err;
26
+ }
27
+ try {
28
+ const content = await fileHandler.readFile("utf-8");
29
+ return JSON.parse(content);
30
+ } finally {
31
+ fileHandler.close();
32
+ }
33
+ };
34
+
35
+ const checkVersion = async (projectPackagePath: string, libPackagePath: string) => {
36
+ const { dependencies } = await readProjectPackage(projectPackagePath);
37
+ const pkg = await readProjectPackage(libPackagePath);
38
+ const range = dependencies?.[pkg.name];
39
+ if (range.startsWith("file:///")) return;
40
+ if (!range) throw new Error(`hint: 在 package.json 的 dependencies 下面没有 ${pkg.name}`);
41
+ if (!semver.satisfies(pkg.version, range))
42
+ throw new Error(
43
+ `hint: ${pkg.name} 版本不匹配, 要求的版本是: ${range}, 实际安装的版本是 ${pkg.version}`,
44
+ );
45
+ };
46
+
47
+ checkVersion(projectPackagePath, libPackagePath);
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "allowSyntheticDefaultImports": true
7
+ },
8
+ "include": ["*.ts"]
9
+ }
package/dist/index.cjs CHANGED
@@ -9,12 +9,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style_css_ts_vanilla = "";
11
11
  const name = "@heycar/heycars-map";
12
- const version = "0.9.7";
12
+ const version = "0.9.8";
13
13
  const type = "module";
14
+ const bin = {
15
+ checkVersion: "./bin/checkVersion.js"
16
+ };
14
17
  const scripts = {
15
18
  dev: "vite -c vite.config.dev.ts",
16
19
  "dev:lib": 'concurrently "vite build -c vite.config.dev.lib.ts --watch --emptyOutDir false" "tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration --watch"',
17
20
  build: "rm -rf dist && vite build && tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration",
21
+ "build:bin": "tsc -p ./bin/tsconfig.json && chmod +x bin/*.js",
18
22
  lint: "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --report-unused-disable-directives --max-warnings 0"
19
23
  };
20
24
  const types = "./dist/index.d.ts";
@@ -53,6 +57,7 @@ const peerDependenciesMeta = {
53
57
  const devDependencies = {
54
58
  "@types/google.maps": "^3.52.0",
55
59
  "@types/lodash-es": "^4.17.6",
60
+ "@types/semver": "^7.5.1",
56
61
  "@typescript-eslint/eslint-plugin": "^5.52.0",
57
62
  "@typescript-eslint/parser": "^5.52.0",
58
63
  "@vanilla-extract/css": "^1.9.5",
@@ -71,6 +76,7 @@ const devDependencies = {
71
76
  "eslint-plugin-prettier": "^4.2.1",
72
77
  "eslint-plugin-vue": "^9.9.0",
73
78
  prettier: "^2.8.4",
79
+ semver: "^7.5.4",
74
80
  typescript: "^4.9.3",
75
81
  "unplugin-vue-jsx": "^0.1.2",
76
82
  vite: "^4.1.0",
@@ -90,6 +96,7 @@ const pkg = {
90
96
  name,
91
97
  version,
92
98
  type,
99
+ bin,
93
100
  scripts,
94
101
  types,
95
102
  module: module$1,
package/dist/index.js CHANGED
@@ -7,12 +7,16 @@ var __publicField = (obj, key, value) => {
7
7
  import Vue, { defineComponent, h, computed, inject, provide, watch, onMounted, onUnmounted, watchPostEffect, shallowRef, ref, watchEffect, reactive, toRefs, toRef } from "vue";
8
8
  const style_css_ts_vanilla = "";
9
9
  const name = "@heycar/heycars-map";
10
- const version = "0.9.7";
10
+ const version = "0.9.8";
11
11
  const type = "module";
12
+ const bin = {
13
+ checkVersion: "./bin/checkVersion.js"
14
+ };
12
15
  const scripts = {
13
16
  dev: "vite -c vite.config.dev.ts",
14
17
  "dev:lib": 'concurrently "vite build -c vite.config.dev.lib.ts --watch --emptyOutDir false" "tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration --watch"',
15
18
  build: "rm -rf dist && vite build && tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration",
19
+ "build:bin": "tsc -p ./bin/tsconfig.json && chmod +x bin/*.js",
16
20
  lint: "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --report-unused-disable-directives --max-warnings 0"
17
21
  };
18
22
  const types = "./dist/index.d.ts";
@@ -51,6 +55,7 @@ const peerDependenciesMeta = {
51
55
  const devDependencies = {
52
56
  "@types/google.maps": "^3.52.0",
53
57
  "@types/lodash-es": "^4.17.6",
58
+ "@types/semver": "^7.5.1",
54
59
  "@typescript-eslint/eslint-plugin": "^5.52.0",
55
60
  "@typescript-eslint/parser": "^5.52.0",
56
61
  "@vanilla-extract/css": "^1.9.5",
@@ -69,6 +74,7 @@ const devDependencies = {
69
74
  "eslint-plugin-prettier": "^4.2.1",
70
75
  "eslint-plugin-vue": "^9.9.0",
71
76
  prettier: "^2.8.4",
77
+ semver: "^7.5.4",
72
78
  typescript: "^4.9.3",
73
79
  "unplugin-vue-jsx": "^0.1.2",
74
80
  vite: "^4.1.0",
@@ -88,6 +94,7 @@ const pkg = {
88
94
  name,
89
95
  version,
90
96
  type,
97
+ bin,
91
98
  scripts,
92
99
  types,
93
100
  module,
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "type": "module",
5
+ "bin": {
6
+ "checkVersion": "./bin/checkVersion.js"
7
+ },
5
8
  "scripts": {
6
9
  "dev": "vite -c vite.config.dev.ts",
7
10
  "dev:lib": "concurrently \"vite build -c vite.config.dev.lib.ts --watch --emptyOutDir false\" \"tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration --watch\"",
8
11
  "build": "rm -rf dist && vite build && tsc --declarationDir dist --emitDeclarationOnly --noEmit false --declaration",
12
+ "build:bin": "tsc -p ./bin/tsconfig.json && chmod +x bin/*.js",
9
13
  "lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --report-unused-disable-directives --max-warnings 0"
10
14
  },
11
15
  "types": "./dist/index.d.ts",
@@ -44,6 +48,7 @@
44
48
  "devDependencies": {
45
49
  "@types/google.maps": "^3.52.0",
46
50
  "@types/lodash-es": "^4.17.6",
51
+ "@types/semver": "^7.5.1",
47
52
  "@typescript-eslint/eslint-plugin": "^5.52.0",
48
53
  "@typescript-eslint/parser": "^5.52.0",
49
54
  "@vanilla-extract/css": "^1.9.5",
@@ -62,6 +67,7 @@
62
67
  "eslint-plugin-prettier": "^4.2.1",
63
68
  "eslint-plugin-vue": "^9.9.0",
64
69
  "prettier": "^2.8.4",
70
+ "semver": "^7.5.4",
65
71
  "typescript": "^4.9.3",
66
72
  "unplugin-vue-jsx": "^0.1.2",
67
73
  "vite": "^4.1.0",
package/tsconfig.json CHANGED
@@ -21,5 +21,6 @@
21
21
  "src/**/*.vue",
22
22
  "../vite.config.dev.ts"
23
23
  ],
24
+ "exclude": ["bin/**/*.*"],
24
25
  "references": [{ "path": "./tsconfig.node.json" }]
25
26
  }