@10stars/config 11.0.4 → 11.0.6
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 +1 -1
- package/src/index.ts +4 -6
- package/src/link-packages.ts +29 -29
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -21,9 +21,9 @@ const getConfig = async (): Promise<Config> =>
|
|
|
21
21
|
)
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const getESLintCommonCmd = async () => {
|
|
25
25
|
const isMonorepo = await checkIsMonorepo(cwd)
|
|
26
|
-
return isMonorepo ? `*/src */*.ts` : `src *.ts`
|
|
26
|
+
return `--ext .ts,.tsx --no-error-on-unmatched-pattern ${isMonorepo ? `*/src */*.ts` : `src *.ts`}`
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const typecheck = () => exec("tsc --project ./tsconfig.json --watch --noEmit")
|
|
@@ -62,13 +62,11 @@ const actions = {
|
|
|
62
62
|
},
|
|
63
63
|
lint: {
|
|
64
64
|
info: "Lint code (in watch mode)",
|
|
65
|
-
action: async () =>
|
|
66
|
-
exec(`esw --watch --ext .ts,.tsx ${await getESLintPaths()}`),
|
|
65
|
+
action: async () => exec(`esw --watch ${await getESLintCommonCmd()}`),
|
|
67
66
|
},
|
|
68
67
|
lintOnce: {
|
|
69
68
|
info: "Lint code (once)",
|
|
70
|
-
action: async () =>
|
|
71
|
-
exec(`eslint --fix --ext .ts,.tsx ${await getESLintPaths()}`),
|
|
69
|
+
action: async () => exec(`eslint --fix ${await getESLintCommonCmd()}`),
|
|
72
70
|
},
|
|
73
71
|
} satisfies Record<string, { info: string; action: () => void | Promise<void> }>
|
|
74
72
|
|
package/src/link-packages.ts
CHANGED
|
@@ -41,35 +41,35 @@ export const linkPackages = async (cwd: string, packagesToLink: string[]) => {
|
|
|
41
41
|
const promises: Promise<unknown>[] = []
|
|
42
42
|
for (const relativePath of packagesToLink) {
|
|
43
43
|
const pathPkg = path.join(cwd, relativePath)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
path.join(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
44
|
+
checkIsMonorepo(pathPkg)
|
|
45
|
+
.catch(() => null) // relative path might point to a non-existing directory for a particular developer; skip linking a particular package in that case
|
|
46
|
+
.then(async (isMonorepo) => {
|
|
47
|
+
if (!isMonorepo) return promises.push(linkPackage(pathPkg))
|
|
48
|
+
|
|
49
|
+
const files = await fs
|
|
50
|
+
.readdir(relativePath, { withFileTypes: true })
|
|
51
|
+
.catch(() => null)
|
|
52
|
+
if (!files) return
|
|
53
|
+
|
|
54
|
+
const directories = files
|
|
55
|
+
.filter((v) => v.isDirectory())
|
|
56
|
+
.map((v) => v.name)
|
|
57
|
+
const packages = (
|
|
58
|
+
await Promise.all(
|
|
59
|
+
directories.map(async (v) => {
|
|
60
|
+
const pathPkg = path.join(cwd, relativePath, v)
|
|
61
|
+
const pkgJson: TF.PackageJson = await import(
|
|
62
|
+
path.join(pathPkg, `package.json`)
|
|
63
|
+
).catch(() => null)
|
|
64
|
+
if (pkgJson) return v
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
).filter(Boolean)
|
|
68
|
+
for (const pkg of packages) {
|
|
69
|
+
const relativePathToPkg = path.join(cwd, relativePath, pkg!)
|
|
70
|
+
promises.push(linkPackage(relativePathToPkg))
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
await Promise.all(promises)
|