@10stars/config 7.1.0 → 7.2.0
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/package.json +5 -2
- package/src/index.ts +0 -0
- package/src/link-packages.ts +36 -0
package/package.json
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
},
|
|
6
6
|
"name": "@10stars/config",
|
|
7
7
|
"description": "10stars.dev Shareable Configs",
|
|
8
|
-
"version": "7.
|
|
8
|
+
"version": "7.2.0",
|
|
9
9
|
"author": "10stars.dev <web@alexandrov.co> (https://alexandrov.co)",
|
|
10
10
|
"keywords": ["config"],
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"module": "./src/index.ts",
|
|
13
|
+
"main": "./src/index.ts",
|
|
12
14
|
"files": [
|
|
15
|
+
"src",
|
|
13
16
|
".eslintrc.js",
|
|
14
17
|
".prettierrc.js",
|
|
15
18
|
"commitlint.config.js",
|
|
@@ -44,6 +47,6 @@
|
|
|
44
47
|
"husky": "^8.0.0",
|
|
45
48
|
"prettier": "^2.0.0",
|
|
46
49
|
"type-fest": "^3.0.0",
|
|
47
|
-
"typescript": "^4.
|
|
50
|
+
"typescript": "^4.9.3"
|
|
48
51
|
}
|
|
49
52
|
}
|
package/src/index.ts
ADDED
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as TF from "type-fest"
|
|
2
|
+
import fs from "node:fs/promises"
|
|
3
|
+
import path from "node:path"
|
|
4
|
+
|
|
5
|
+
const symlink = async (pathTarget: string, pathSymlink: string) => {
|
|
6
|
+
const stats = await fs.lstat(pathSymlink).catch(() => null)
|
|
7
|
+
if (!stats) return
|
|
8
|
+
|
|
9
|
+
if (stats.isSymbolicLink()) {
|
|
10
|
+
const symlinkRealpath = await fs.realpath(pathSymlink).catch(() => null)
|
|
11
|
+
if (pathTarget === symlinkRealpath) return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (stats.isDirectory()) await fs.rm(pathSymlink, { recursive: true })
|
|
15
|
+
else await fs.unlink(pathSymlink)
|
|
16
|
+
|
|
17
|
+
await fs.symlink(pathTarget, pathSymlink)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const linkPackages = async (
|
|
21
|
+
cwd: string,
|
|
22
|
+
relativePathsToPkgs: string[],
|
|
23
|
+
) => {
|
|
24
|
+
const linkPackage = async (relativePathToPkg: string) => {
|
|
25
|
+
const pkgJson: TF.PackageJson = await import(
|
|
26
|
+
`${relativePathToPkg}/package.json`
|
|
27
|
+
)
|
|
28
|
+
const [orgName, pkgName] = pkgJson.name!.split(`/`)
|
|
29
|
+
|
|
30
|
+
const pathTarget = path.join(cwd, relativePathToPkg)
|
|
31
|
+
const pathSymlink = path.join(cwd, `node_modules`, orgName, pkgName)
|
|
32
|
+
return symlink(pathTarget, pathSymlink)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return Promise.all(relativePathsToPkgs.map(linkPackage))
|
|
36
|
+
}
|