@mark1russell7/conventions 0.47.4 → 0.48.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/README.md +4 -2
- package/build/cli.js +1 -1
- package/build/index.d.ts +3 -3
- package/build/index.js +3 -3
- package/build/{run-PzdziLsV.js → run-BonUEmhi.js} +6 -3
- package/build/run-BonUEmhi.js.map +1 -0
- package/build/{workspace-BMtl0EQf.d.ts → workspace-BjoLngtR.d.ts} +17 -5
- package/build/workspace-BjoLngtR.d.ts.map +1 -0
- package/build/{workspace-Cx7p7bWn.js → workspace-_CIq-8ei.js} +74 -24
- package/build/workspace-_CIq-8ei.js.map +1 -0
- package/build/workspace.d.ts +2 -2
- package/build/workspace.js +1 -1
- package/package.json +6 -3
- package/build/run-PzdziLsV.js.map +0 -1
- package/build/workspace-BMtl0EQf.d.ts.map +0 -1
- package/build/workspace-Cx7p7bWn.js.map +0 -1
|
@@ -9,6 +9,18 @@ declare function globToRegExp(glob: string): RegExp;
|
|
|
9
9
|
* in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.
|
|
10
10
|
*/
|
|
11
11
|
declare function globFolders(root: string, glob: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* This function gives the `packages` list of the text of a `pnpm-workspace.yaml` file, or undefined when the file has
|
|
14
|
+
* no key `packages`. It reads a block list (also at the column of the key) and a flow list on one or more lines. It
|
|
15
|
+
* throws on each other form, because a list that it reads in part names too few packages.
|
|
16
|
+
*/
|
|
17
|
+
declare function parseWorkspaceGlobs(text: string): string[] | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* This function tells if a folder is a package folder of the workspace globs, as in pnpm. The folder is a `/` path
|
|
20
|
+
* relative to the root, or `.` for the root. A glob matches it, and no `!` glob matches it. No part of it starts with
|
|
21
|
+
* `.` or is a folder of the default ignore of pnpm. The function does not look for a `package.json` file.
|
|
22
|
+
*/
|
|
23
|
+
declare function isWorkspaceFolder(folder: string, globs: readonly string[]): boolean;
|
|
12
24
|
/**
|
|
13
25
|
* This function gives the globs of the workspace at `root`: the `packages` list of
|
|
14
26
|
* `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when
|
|
@@ -17,9 +29,9 @@ declare function globFolders(root: string, glob: string): string[];
|
|
|
17
29
|
declare function workspaceGlobs(root: string): string[] | undefined;
|
|
18
30
|
/**
|
|
19
31
|
* This function gives the package folders of the repository at `root`: the folders of the globs
|
|
20
|
-
* that have a `package.json` file. A glob that starts with `!` removes folders
|
|
21
|
-
* function reads the globs of the workspace, and a repository with no
|
|
22
|
-
* The result has absolute paths, in the order of the code units.
|
|
32
|
+
* that have a `package.json` file. A glob that starts with `!` removes folders, and so does the default ignore of pnpm
|
|
33
|
+
* (`isWorkspaceFolder`). Without globs, the function reads the globs of the workspace, and a repository with no
|
|
34
|
+
* workspace is one package. The result has absolute paths, in the order of the code units.
|
|
23
35
|
*/
|
|
24
36
|
declare function packageFolders(root: string, globs?: readonly string[] | undefined): string[];
|
|
25
37
|
/**
|
|
@@ -29,5 +41,5 @@ declare function packageFolders(root: string, globs?: readonly string[] | undefi
|
|
|
29
41
|
* workspace. The result has absolute paths, in the order of the code units.
|
|
30
42
|
*/
|
|
31
43
|
declare function reportFolders(root: string, globs?: readonly string[]): string[];
|
|
32
|
-
export {
|
|
33
|
-
//# sourceMappingURL=workspace-
|
|
44
|
+
export { parseWorkspaceGlobs as a, packageFolders as i, globToRegExp as n, reportFolders as o, isWorkspaceFolder as r, workspaceGlobs as s, globFolders as t };
|
|
45
|
+
//# sourceMappingURL=workspace-BjoLngtR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-BjoLngtR.d.ts","names":[],"sources":["../src/workspace.ts"],"mappings":";;;;;iBAsBgB,aAAa,eAAe;;;;;iBAsD5B,YAAY,cAAc;;;;;;iBA6C1B,oBAAoB;;;;;;iBA4CpB,kBAAkB,gBAAgB;;;;;;iBAWlC,eAAe;;;;;;;iBAuBf,eAAe,cAAc;;;;;;;iBAiB7B,cAAc,cAAc"}
|
|
@@ -90,6 +90,70 @@ function globFolders(root, glob) {
|
|
|
90
90
|
return found.sort(byCode);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
+
* This function removes a comment at the end of a line of YAML: the first `#` after a space, and the text after it.
|
|
94
|
+
* The caller trims the spaces before it. A search for one space and a `#` takes linear time on each text.
|
|
95
|
+
*/
|
|
96
|
+
function stripComment(text) {
|
|
97
|
+
const at = text.search(/\s#/);
|
|
98
|
+
return at < 0 ? text : text.slice(0, at);
|
|
99
|
+
}
|
|
100
|
+
/** This function removes a comment at the end of a YAML value, the spaces and the quotes around it. */
|
|
101
|
+
function unquote(text) {
|
|
102
|
+
const value = stripComment(text).trim();
|
|
103
|
+
return /^(["']).*\1$/.test(value) ? value.slice(1, -1) : value;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* This function gives the `packages` list of the text of a `pnpm-workspace.yaml` file, or undefined when the file has
|
|
107
|
+
* no key `packages`. It reads a block list (also at the column of the key) and a flow list on one or more lines. It
|
|
108
|
+
* throws on each other form, because a list that it reads in part names too few packages.
|
|
109
|
+
*/
|
|
110
|
+
function parseWorkspaceGlobs(text) {
|
|
111
|
+
const lines = text.split(/\r?\n/);
|
|
112
|
+
const start = lines.findIndex((line) => /^packages\s*:/.test(line));
|
|
113
|
+
if (start < 0) return void 0;
|
|
114
|
+
const rest = stripComment((lines[start] ?? "").replace(/^packages\s*:/, "")).trim();
|
|
115
|
+
if (rest.startsWith("[")) {
|
|
116
|
+
let flow = rest;
|
|
117
|
+
for (let index = start + 1; !flow.includes("]"); index++) {
|
|
118
|
+
if (index >= lines.length) throw new Error("The list packages of pnpm-workspace.yaml has no \"]\"");
|
|
119
|
+
flow += ` ${stripComment(lines[index] ?? "")}`;
|
|
120
|
+
}
|
|
121
|
+
const close = flow.indexOf("]");
|
|
122
|
+
if (flow.slice(close + 1).trim() !== "") throw new Error(`The list packages of pnpm-workspace.yaml has text after its "]": ${flow}`);
|
|
123
|
+
return flow.slice(1, close).split(",").map(unquote).filter((glob) => glob !== "");
|
|
124
|
+
}
|
|
125
|
+
if (rest !== "") throw new Error(`The key packages of pnpm-workspace.yaml is not a list: ${rest}`);
|
|
126
|
+
const globs = [];
|
|
127
|
+
for (const line of lines.slice(start + 1)) {
|
|
128
|
+
if (/^\s*(#.*)?$/.test(line)) continue;
|
|
129
|
+
const item = /^\s*-\s(.+)$/.exec(line);
|
|
130
|
+
if (item) {
|
|
131
|
+
globs.push(unquote(item[1] ?? ""));
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!/^\s/.test(line)) break;
|
|
135
|
+
throw new Error(`A line of the list packages of pnpm-workspace.yaml is not an item: ${line.trim()}`);
|
|
136
|
+
}
|
|
137
|
+
return globs;
|
|
138
|
+
}
|
|
139
|
+
/** The folders that pnpm does not take as packages of a workspace: the default ignore of its search for packages. */
|
|
140
|
+
const IGNORED_FOLDERS = /* @__PURE__ */ new Set([
|
|
141
|
+
"node_modules",
|
|
142
|
+
"bower_components",
|
|
143
|
+
"test",
|
|
144
|
+
"tests"
|
|
145
|
+
]);
|
|
146
|
+
/**
|
|
147
|
+
* This function tells if a folder is a package folder of the workspace globs, as in pnpm. The folder is a `/` path
|
|
148
|
+
* relative to the root, or `.` for the root. A glob matches it, and no `!` glob matches it. No part of it starts with
|
|
149
|
+
* `.` or is a folder of the default ignore of pnpm. The function does not look for a `package.json` file.
|
|
150
|
+
*/
|
|
151
|
+
function isWorkspaceFolder(folder, globs) {
|
|
152
|
+
if (folder.split("/").some((part) => part !== "." && part.startsWith(".") || IGNORED_FOLDERS.has(part))) return false;
|
|
153
|
+
const matches = (glob) => globToRegExp(trimEndSlashes(glob.startsWith("./") ? glob.slice(2) : glob)).test(folder);
|
|
154
|
+
return globs.some((glob) => !glob.startsWith("!") && matches(glob)) && !globs.some((glob) => glob.startsWith("!") && matches(glob.slice(1)));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
93
157
|
* This function gives the globs of the workspace at `root`: the `packages` list of
|
|
94
158
|
* `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when
|
|
95
159
|
* the repository has no workspace.
|
|
@@ -97,21 +161,8 @@ function globFolders(root, glob) {
|
|
|
97
161
|
function workspaceGlobs(root) {
|
|
98
162
|
const yaml = join(root, "pnpm-workspace.yaml");
|
|
99
163
|
if (existsSync(yaml)) {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
if (start >= 0) {
|
|
103
|
-
const unquote = (text) => text.replace(/\s+#.*$/, "").trim().replace(/^["']|["']$/g, "");
|
|
104
|
-
const inline = /^packages\s*:\s*\[(.*)\]/.exec(lines[start] ?? "");
|
|
105
|
-
if (inline) return (inline[1] ?? "").split(",").map(unquote).filter(Boolean);
|
|
106
|
-
const globs = [];
|
|
107
|
-
for (const line of lines.slice(start + 1)) {
|
|
108
|
-
if (/^\s*(#.*)?$/.test(line)) continue;
|
|
109
|
-
const item = /^\s+-\s+(.+)$/.exec(line);
|
|
110
|
-
if (!item) break;
|
|
111
|
-
globs.push(unquote(item[1] ?? ""));
|
|
112
|
-
}
|
|
113
|
-
return globs;
|
|
114
|
-
}
|
|
164
|
+
const globs = parseWorkspaceGlobs(readFileSync(yaml, "utf8"));
|
|
165
|
+
if (globs !== void 0) return globs;
|
|
115
166
|
}
|
|
116
167
|
const manifestFile = join(root, "package.json");
|
|
117
168
|
if (existsSync(manifestFile)) {
|
|
@@ -122,16 +173,15 @@ function workspaceGlobs(root) {
|
|
|
122
173
|
}
|
|
123
174
|
/**
|
|
124
175
|
* This function gives the package folders of the repository at `root`: the folders of the globs
|
|
125
|
-
* that have a `package.json` file. A glob that starts with `!` removes folders
|
|
126
|
-
* function reads the globs of the workspace, and a repository with no
|
|
127
|
-
* The result has absolute paths, in the order of the code units.
|
|
176
|
+
* that have a `package.json` file. A glob that starts with `!` removes folders, and so does the default ignore of pnpm
|
|
177
|
+
* (`isWorkspaceFolder`). Without globs, the function reads the globs of the workspace, and a repository with no
|
|
178
|
+
* workspace is one package. The result has absolute paths, in the order of the code units.
|
|
128
179
|
*/
|
|
129
180
|
function packageFolders(root, globs = workspaceGlobs(root)) {
|
|
130
181
|
if (globs === void 0) return existsSync(join(root, "package.json")) ? [root] : [];
|
|
131
|
-
const
|
|
132
|
-
for (const glob of globs.filter((item) => !item.startsWith("!"))) for (const folder of globFolders(root, glob))
|
|
133
|
-
|
|
134
|
-
return [...included].filter((folder) => existsSync(join(root, folder, "package.json"))).sort(byCode).map((folder) => join(root, folder));
|
|
182
|
+
const found = /* @__PURE__ */ new Set();
|
|
183
|
+
for (const glob of globs.filter((item) => !item.startsWith("!"))) for (const folder of globFolders(root, glob)) found.add(folder);
|
|
184
|
+
return [...found].filter((folder) => isWorkspaceFolder(folder, globs) && existsSync(join(root, folder, "package.json"))).sort(byCode).map((folder) => join(root, folder));
|
|
135
185
|
}
|
|
136
186
|
/**
|
|
137
187
|
* This function gives the folders of the reports when the command names no folder. With `globs`, these are the package
|
|
@@ -151,6 +201,6 @@ function reportFolders(root, globs) {
|
|
|
151
201
|
} catch {}
|
|
152
202
|
return isPrivate ? folders : [top, ...folders];
|
|
153
203
|
}
|
|
154
|
-
export {
|
|
204
|
+
export { packageFolders as a, reportFolders as c, isWorkspaceFolder as i, workspaceGlobs as l, globFolders as n, parseWorkspaceGlobs as o, globToRegExp as r, relativePath as s, byCode as t };
|
|
155
205
|
|
|
156
|
-
//# sourceMappingURL=workspace-
|
|
206
|
+
//# sourceMappingURL=workspace-_CIq-8ei.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-_CIq-8ei.js","names":[],"sources":["../src/workspace.ts"],"sourcesContent":["/**\n * The package folders of a repository: the folders that the globs of the workspace name, with a\n * `package.json` file. This file is the one home of this code. The subpath\n * `@mark1russell7/conventions/workspace` exports it, and `@mark1russell7/api-report` imports it from there.\n */\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, relative, resolve, sep } from \"node:path\";\n\n/** This function compares two strings by their code units, as the default sort does. */\nexport const byCode = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** This function gives a path relative to `root`, with `/`. */\nexport const relativePath = (root: string, file: string): string => relative(root, file).split(sep).join(\"/\");\n\n/** The characters that have a meaning in a regular expression. */\nconst SPECIAL = new Set([...\"\\\\^$.|+()[]{}*?/\"]);\n\n/**\n * This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path\n * segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of\n * its parts. The function escapes each other special character.\n */\nexport function globToRegExp(glob: string): RegExp {\n let source = \"\";\n let braces = 0;\n for (let index = 0; index < glob.length; index++) {\n const char = glob.charAt(index);\n if (char === \"/\" && glob.slice(index + 1) === \"**\") {\n // `a/**` matches `a` and each path under it\n source += \"(?:/.*)?\";\n break;\n }\n if (char === \"*\" && glob.charAt(index + 1) === \"*\") {\n const atStart = index === 0 || glob.charAt(index - 1) === \"/\";\n const after = glob.charAt(index + 2);\n if (atStart && after === \"/\") {\n // `**/` matches zero or more whole segments\n source += \"(?:[^/]+/)*\";\n index += 2;\n } else if (atStart && after === \"\") {\n source += \".*\";\n index += 1;\n } else {\n source += \"[^/]*\";\n index += 1;\n }\n } else if (char === \"*\") source += \"[^/]*\";\n else if (char === \"?\") source += \"[^/]\";\n else if (char === \"{\") {\n braces++;\n source += \"(?:\";\n } else if (char === \"}\" && braces > 0) {\n braces--;\n source += \")\";\n } else if (char === \",\" && braces > 0) source += \"|\";\n else if (SPECIAL.has(char)) source += `\\\\${char}`;\n else source += char;\n }\n if (braces > 0) throw new Error(`A glob with a \"{\" that has no \"}\": ${glob}`);\n return new RegExp(`^${source}$`);\n}\n\n/** The characters that make a path segment a pattern. */\nconst GLOB_CHARS = /[*?{]/;\n\n/** This function removes the `/` characters at the end of a path, with a loop in place of a regular expression. */\nfunction trimEndSlashes(path: string): string {\n let end = path.length;\n while (end > 0 && path.charAt(end - 1) === \"/\") end -= 1;\n return path.slice(0, end);\n}\n\n/**\n * This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,\n * in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.\n */\nexport function globFolders(root: string, glob: string): string[] {\n const clean = trimEndSlashes(glob.startsWith(\"./\") ? glob.slice(2) : glob);\n const segments = clean.split(\"/\");\n const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));\n if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];\n const base = segments.slice(0, firstPattern).join(\"/\");\n const depth = clean.includes(\"**\") ? Number.POSITIVE_INFINITY : segments.length - firstPattern;\n const pattern = globToRegExp(clean);\n const start = join(root, base);\n if (!existsSync(start)) return [];\n const found: string[] = [];\n const walk = (folder: string, level: number): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const path = join(folder, entry.name);\n if (pattern.test(relativePath(root, path))) found.push(relativePath(root, path));\n if (level < depth) walk(path, level + 1);\n }\n };\n // `a/**` also names `a`\n if (base !== \"\" && pattern.test(base)) found.push(base);\n walk(start, 1);\n return found.sort(byCode);\n}\n\n/**\n * This function removes a comment at the end of a line of YAML: the first `#` after a space, and the text after it.\n * The caller trims the spaces before it. A search for one space and a `#` takes linear time on each text.\n */\nfunction stripComment(text: string): string {\n const at = text.search(/\\s#/);\n return at < 0 ? text : text.slice(0, at);\n}\n\n/** This function removes a comment at the end of a YAML value, the spaces and the quotes around it. */\nfunction unquote(text: string): string {\n const value = stripComment(text).trim();\n return /^([\"']).*\\1$/.test(value) ? value.slice(1, -1) : value;\n}\n\n/**\n * This function gives the `packages` list of the text of a `pnpm-workspace.yaml` file, or undefined when the file has\n * no key `packages`. It reads a block list (also at the column of the key) and a flow list on one or more lines. It\n * throws on each other form, because a list that it reads in part names too few packages.\n */\nexport function parseWorkspaceGlobs(text: string): string[] | undefined {\n const lines = text.split(/\\r?\\n/);\n const start = lines.findIndex((line) => /^packages\\s*:/.test(line));\n if (start < 0) return undefined;\n const rest = stripComment((lines[start] ?? \"\").replace(/^packages\\s*:/, \"\")).trim();\n if (rest.startsWith(\"[\")) {\n let flow = rest;\n for (let index = start + 1; !flow.includes(\"]\"); index++) {\n if (index >= lines.length) throw new Error('The list packages of pnpm-workspace.yaml has no \"]\"');\n flow += ` ${stripComment(lines[index] ?? \"\")}`;\n }\n const close = flow.indexOf(\"]\");\n if (flow.slice(close + 1).trim() !== \"\") throw new Error(`The list packages of pnpm-workspace.yaml has text after its \"]\": ${flow}`);\n return flow\n .slice(1, close)\n .split(\",\")\n .map(unquote)\n .filter((glob) => glob !== \"\");\n }\n if (rest !== \"\") throw new Error(`The key packages of pnpm-workspace.yaml is not a list: ${rest}`);\n const globs: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (/^\\s*(#.*)?$/.test(line)) continue;\n const item = /^\\s*-\\s(.+)$/.exec(line);\n if (item) {\n globs.push(unquote(item[1] ?? \"\"));\n continue;\n }\n // A line at the column of the key starts the next key. An indented line that is not an item is a form that this\n // function does not read.\n if (!/^\\s/.test(line)) break;\n throw new Error(`A line of the list packages of pnpm-workspace.yaml is not an item: ${line.trim()}`);\n }\n return globs;\n}\n\n/** The folders that pnpm does not take as packages of a workspace: the default ignore of its search for packages. */\nconst IGNORED_FOLDERS = new Set([\"node_modules\", \"bower_components\", \"test\", \"tests\"]);\n\n/**\n * This function tells if a folder is a package folder of the workspace globs, as in pnpm. The folder is a `/` path\n * relative to the root, or `.` for the root. A glob matches it, and no `!` glob matches it. No part of it starts with\n * `.` or is a folder of the default ignore of pnpm. The function does not look for a `package.json` file.\n */\nexport function isWorkspaceFolder(folder: string, globs: readonly string[]): boolean {\n if (folder.split(\"/\").some((part) => (part !== \".\" && part.startsWith(\".\")) || IGNORED_FOLDERS.has(part))) return false;\n const matches = (glob: string): boolean => globToRegExp(trimEndSlashes(glob.startsWith(\"./\") ? glob.slice(2) : glob)).test(folder);\n return globs.some((glob) => !glob.startsWith(\"!\") && matches(glob)) && !globs.some((glob) => glob.startsWith(\"!\") && matches(glob.slice(1)));\n}\n\n/**\n * This function gives the globs of the workspace at `root`: the `packages` list of\n * `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when\n * the repository has no workspace.\n */\nexport function workspaceGlobs(root: string): string[] | undefined {\n const yaml = join(root, \"pnpm-workspace.yaml\");\n if (existsSync(yaml)) {\n const globs = parseWorkspaceGlobs(readFileSync(yaml, \"utf8\"));\n if (globs !== undefined) return globs;\n }\n const manifestFile = join(root, \"package.json\");\n if (existsSync(manifestFile)) {\n const { workspaces } = JSON.parse(readFileSync(manifestFile, \"utf8\")) as { workspaces?: unknown };\n if (Array.isArray(workspaces)) return workspaces.filter((glob): glob is string => typeof glob === \"string\");\n if (typeof workspaces === \"object\" && workspaces !== null && \"packages\" in workspaces && Array.isArray(workspaces.packages)) {\n return workspaces.packages.filter((glob): glob is string => typeof glob === \"string\");\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the package folders of the repository at `root`: the folders of the globs\n * that have a `package.json` file. A glob that starts with `!` removes folders, and so does the default ignore of pnpm\n * (`isWorkspaceFolder`). Without globs, the function reads the globs of the workspace, and a repository with no\n * workspace is one package. The result has absolute paths, in the order of the code units.\n */\nexport function packageFolders(root: string, globs: readonly string[] | undefined = workspaceGlobs(root)): string[] {\n if (globs === undefined) return existsSync(join(root, \"package.json\")) ? [root] : [];\n const found = new Set<string>();\n for (const glob of globs.filter((item) => !item.startsWith(\"!\"))) for (const folder of globFolders(root, glob)) found.add(folder);\n // As in pnpm, a `!` glob removes its folders in each position of the list\n return [...found]\n .filter((folder) => isWorkspaceFolder(folder, globs) && existsSync(join(root, folder, \"package.json\")))\n .sort(byCode)\n .map((folder) => join(root, folder));\n}\n\n/**\n * This function gives the folders of the reports when the command names no folder. With `globs`, these are the package\n * folders of the globs. Without `globs`, these are the package folders of the workspace, and also the root when its\n * package is public and the globs leave it out. A repository can publish its root and keep a private site in its\n * workspace. The result has absolute paths, in the order of the code units.\n */\nexport function reportFolders(root: string, globs?: readonly string[]): string[] {\n if (globs !== undefined) return packageFolders(root, globs);\n const folders = packageFolders(root);\n const top = resolve(root);\n const manifest = join(top, \"package.json\");\n if (workspaceGlobs(root) === undefined || !existsSync(manifest) || folders.some((folder) => resolve(folder) === top)) return folders;\n let isPrivate = false;\n try {\n isPrivate = (JSON.parse(readFileSync(manifest, \"utf8\")) as { private?: unknown }).private === true;\n } catch {\n // The run reads the file again and tells the error of the root\n }\n return isPrivate ? folders : [top, ...folders];\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,UAAU,GAAW,MAAuB,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;;AAGlF,MAAa,gBAAgB,MAAc,SAAyB,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;;AAG5G,MAAM,0BAAU,IAAI,IAAI,CAAC,GAAG,kBAAkB,CAAC;;;;;;AAO/C,SAAgB,aAAa,MAAsB;CACjD,IAAI,SAAS;CACb,IAAI,SAAS;CACb,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,MAAM,OAAO,KAAK,OAAO,KAAK;EAC9B,IAAI,SAAS,OAAO,KAAK,MAAM,QAAQ,CAAC,MAAM,MAAM;GAElD,UAAU;GACV;EACF;EACA,IAAI,SAAS,OAAO,KAAK,OAAO,QAAQ,CAAC,MAAM,KAAK;GAClD,MAAM,UAAU,UAAU,KAAK,KAAK,OAAO,QAAQ,CAAC,MAAM;GAC1D,MAAM,QAAQ,KAAK,OAAO,QAAQ,CAAC;GACnC,IAAI,WAAW,UAAU,KAAK;IAE5B,UAAU;IACV,SAAS;GACX,OAAO,IAAI,WAAW,UAAU,IAAI;IAClC,UAAU;IACV,SAAS;GACX,OAAO;IACL,UAAU;IACV,SAAS;GACX;EACF,OAAO,IAAI,SAAS,KAAK,UAAU;OAC9B,IAAI,SAA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KAAa,CAAC,WAAW,QAAQ,KAAK,QAAQ,MAAM,WAAW,QAAQ,MAAM,MAAM,GAAG,GAAG,OAAO;CAC7H,IAAI,YAAY;CAChB,IAAI;EACF,YAAa,KAAK,MAAM,aAAa,UAAU,MAAM,CAAC,CAAC,CAA2B,YAAY;CAChG,QAAQ,CAER;CACA,OAAO,YAAY,UAAU,CAAC,KAAK,GAAG,OAAO;AAC/C"}
|
package/build/workspace.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* The entry of the subpath `@mark1russell7/conventions/workspace`. It gives the functions that find the
|
|
3
3
|
* package folders of a repository. `@mark1russell7/api-report` imports them from here.
|
|
4
4
|
*/
|
|
5
|
-
import { a as
|
|
6
|
-
export { globFolders, globToRegExp, packageFolders, reportFolders, workspaceGlobs };
|
|
5
|
+
import { a as parseWorkspaceGlobs, i as packageFolders, n as globToRegExp, o as reportFolders, r as isWorkspaceFolder, s as workspaceGlobs, t as globFolders } from "./workspace-BjoLngtR.js";
|
|
6
|
+
export { globFolders, globToRegExp, isWorkspaceFolder, packageFolders, parseWorkspaceGlobs, reportFolders, workspaceGlobs };
|
package/build/workspace.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as globFolders, r as globToRegExp, i as packageFolders, o as reportFolders,
|
|
1
|
+
export { n as globFolders, r as globToRegExp, i as isWorkspaceFolder, a as packageFolders, o as parseWorkspaceGlobs, c as reportFolders, l as workspaceGlobs } from "./workspace-_CIq-8ei.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/conventions",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.0",
|
|
5
5
|
"description": "One check in CI for the conventions of a pnpm workspace that docs tell in prose: pinned git dependencies, source packages, tsconfig.test.json, no build output in git and more.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"conventions",
|
|
@@ -58,8 +58,10 @@
|
|
|
58
58
|
"node": ">=22"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
+
"@mark1russell7/collections": "^0.11.3",
|
|
61
62
|
"@mark1russell7/cue": "^2.0.0",
|
|
62
|
-
"@mark1russell7/
|
|
63
|
+
"@mark1russell7/files": "^0.0.4",
|
|
64
|
+
"@mark1russell7/site-pages": "0.8.1",
|
|
63
65
|
"@types/node": "^26.6.4",
|
|
64
66
|
"@vitest/coverage-v8": "^5.0.3",
|
|
65
67
|
"tsdown": "^0.23.1",
|
|
@@ -67,11 +69,12 @@
|
|
|
67
69
|
"vitest": "^5.0.3"
|
|
68
70
|
},
|
|
69
71
|
"dependencies": {
|
|
70
|
-
"@mark1russell7/text": "^0.0.
|
|
72
|
+
"@mark1russell7/text": "^0.0.16",
|
|
71
73
|
"yaml": "^2.9.1"
|
|
72
74
|
},
|
|
73
75
|
"scripts": {
|
|
74
76
|
"build": "tsdown",
|
|
77
|
+
"build:actions": "tsdown -c tsdown.actions.config.ts",
|
|
75
78
|
"test": "vitest run",
|
|
76
79
|
"test:watch": "vitest",
|
|
77
80
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json"
|