@10stars/config 7.2.2 → 7.3.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.
@@ -1,15 +1,14 @@
1
1
  module.exports = {
2
2
  extends: [`@commitlint/config-conventional`],
3
+ /**
4
+ * For explanation on how to write rules @see https://commitlint.js.org/#/reference-rules
5
+ */
3
6
  rules: {
4
7
  "body-leading-blank": [1, `always`],
5
8
  "footer-leading-blank": [1, `always`],
6
9
  "header-max-length": [2, `always`, 72],
7
10
  "scope-case": [2, `always`, `lower-case`],
8
- "subject-case": [
9
- 2,
10
- `never`,
11
- [`sentence-case`, `start-case`, `pascal-case`, `upper-case`],
12
- ],
11
+ "subject-case": [2, `never`, [`start-case`, `pascal-case`, `upper-case`]],
13
12
  "subject-empty": [2, `never`],
14
13
  "subject-full-stop": [2, `never`, `.`],
15
14
  "type-case": [2, `always`, `upper-case`],
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "name": "@10stars/config",
7
- "version": "7.2.2",
7
+ "version": "7.3.0",
8
8
  "author": "10stars.dev <web@alexandrov.co> (https://alexandrov.co)",
9
9
  "license": "MIT",
10
10
  "module": "./src/index.ts",
@@ -32,7 +32,7 @@
32
32
  "@typescript-eslint/eslint-plugin": "^5.0.0",
33
33
  "@typescript-eslint/parser": "^5.0.0",
34
34
  "builtin-modules": "^3.3.0",
35
- "esbuild": "~0.15.10",
35
+ "esbuild": "~0.16.10",
36
36
  "tsx": "^3.8.0",
37
37
  "eslint": "^8.0.0",
38
38
  "eslint-config-prettier": "^8.0.0",
@@ -1,7 +1,8 @@
1
- import type * as TF from "type-fest"
2
1
  import fs from "node:fs/promises"
3
2
  import path from "node:path"
4
3
 
4
+ import type * as TF from "type-fest"
5
+
5
6
  const symlink = async (pathTarget: string, pathSymlink: string) => {
6
7
  const stats = await fs.lstat(pathSymlink).catch(() => null)
7
8
  if (!stats) return
@@ -19,13 +20,15 @@ const symlink = async (pathTarget: string, pathSymlink: string) => {
19
20
 
20
21
  export const linkPackages = async (
21
22
  cwd: string,
22
- relativePathsToPkgs: string[],
23
+ packagesToLink: { relativePath: string; isMonorepo?: boolean }[],
23
24
  ) => {
24
25
  const linkPackage = async (relativePathToPkg: string) => {
25
26
  const pathPkg = path.join(cwd, relativePathToPkg)
26
27
  const pkgJson: TF.PackageJson = await import(
27
28
  path.join(pathPkg, `package.json`)
28
- )
29
+ ).catch(() => null)
30
+ if (!pkgJson) return
31
+
29
32
  const [orgName, pkgName] = pkgJson.name!.split(`/`)
30
33
 
31
34
  const pathTarget = path.join(cwd, relativePathToPkg)
@@ -33,5 +36,33 @@ export const linkPackages = async (
33
36
  return symlink(pathTarget, pathSymlink)
34
37
  }
35
38
 
36
- return Promise.all(relativePathsToPkgs.map(linkPackage))
39
+ const promises: Promise<unknown>[] = []
40
+ for (const packageToLink of packagesToLink) {
41
+ if (!packageToLink.isMonorepo) {
42
+ promises.push(linkPackage(packageToLink.relativePath))
43
+ continue
44
+ }
45
+
46
+ const files = await fs.readdir(packageToLink.relativePath, {
47
+ withFileTypes: true,
48
+ })
49
+ const directories = files.filter((v) => v.isDirectory()).map((v) => v.name)
50
+ const packages = (
51
+ await Promise.all(
52
+ directories.map(async (v) => {
53
+ const pathPkg = path.join(cwd, packageToLink.relativePath, v)
54
+ const pkgJson: TF.PackageJson = await import(
55
+ path.join(pathPkg, `package.json`)
56
+ ).catch(() => null)
57
+ if (pkgJson) return v
58
+ }),
59
+ )
60
+ ).filter(Boolean)
61
+ for (const pkg of packages) {
62
+ const relativePathToPkg = path.join(cwd, packageToLink.relativePath, pkg!)
63
+ promises.push(linkPackage(relativePathToPkg))
64
+ }
65
+ }
66
+
67
+ return Promise.all(promises)
37
68
  }