nx-npm-tools 1.0.3 → 1.1.1
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 +25 -0
- package/dist/commands/statusStation.js +166 -0
- package/dist/commands/statusStation.js.map +1 -0
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/prometheus.js +57 -2
- package/dist/utils/prometheus.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,15 @@ Install globally:
|
|
|
6
6
|
npm i -g nx-npm-tools
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
Check installed version:
|
|
10
|
+
```bash
|
|
11
|
+
# Check version of nx-npm-tools
|
|
12
|
+
nx-npm-tools --version
|
|
13
|
+
|
|
14
|
+
# See all globally installed packages (for visibility)
|
|
15
|
+
npm list -g --depth=0
|
|
16
|
+
```
|
|
17
|
+
|
|
9
18
|
## Prometheus mode (default)
|
|
10
19
|
|
|
11
20
|
If you run commands without `--path`, it auto-walks upward until it finds a folder named `prometheus` and uses it as the station root.
|
|
@@ -163,6 +172,22 @@ nx-npm-tools publishOne --cwd . --access public --bump patch
|
|
|
163
172
|
nx-npm-tools gitSync --message "publishing"
|
|
164
173
|
```
|
|
165
174
|
|
|
175
|
+
### statusStation (publishing status report)
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# Generate status report showing what's published vs what needs publishing
|
|
179
|
+
npx nx-npm-tools statusStation --pro --out station-status.md
|
|
180
|
+
|
|
181
|
+
# Skip npm registry checks (faster, less accurate)
|
|
182
|
+
npx nx-npm-tools statusStation --pro --skip-npm-check
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Shows:
|
|
186
|
+
- ✅ Published and up-to-date packages
|
|
187
|
+
- 📦 Packages needing publication (new or version updates)
|
|
188
|
+
- ❌ Packages not published
|
|
189
|
+
- ⚠️ Check errors (network/registry issues)
|
|
190
|
+
|
|
166
191
|
### archiveExcluded (move excluded packages to archive)
|
|
167
192
|
|
|
168
193
|
```bash
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveStationRoot } from "../utils/path.js";
|
|
4
|
+
import { discoverStationInventory } from "../station/discover.js";
|
|
5
|
+
import { buildStationGraph } from "../station/graph.js";
|
|
6
|
+
import { writeText } from "../utils/fs.js";
|
|
7
|
+
import { runCapture } from "../utils/exec.js";
|
|
8
|
+
async function checkNpmPackageStatus(pkgName, localVersion) {
|
|
9
|
+
try {
|
|
10
|
+
// Try to get package version from npm (just the version, simpler)
|
|
11
|
+
const output = await runCapture("npm", ["view", pkgName, "version"], process.cwd());
|
|
12
|
+
const version = output.trim();
|
|
13
|
+
if (!version || version.length === 0) {
|
|
14
|
+
return { published: false };
|
|
15
|
+
}
|
|
16
|
+
// Clean up version string (remove any extra formatting)
|
|
17
|
+
const cleanVersion = version.replace(/^version\s*=\s*['"]?/, "").replace(/['"]\s*$/, "").trim();
|
|
18
|
+
return {
|
|
19
|
+
published: true,
|
|
20
|
+
latest: cleanVersion
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
// Package might not exist or network error
|
|
25
|
+
const errorMsg = error?.message ?? String(error);
|
|
26
|
+
const stderr = error?.stderr ?? "";
|
|
27
|
+
if (errorMsg.includes("404") || errorMsg.includes("not found") || stderr.includes("404")) {
|
|
28
|
+
return { published: false };
|
|
29
|
+
}
|
|
30
|
+
return { published: false, error: errorMsg };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function statusStationCommand() {
|
|
34
|
+
return new Command("statusStation")
|
|
35
|
+
.description("Generate a status report showing which packages are published and which need publishing.")
|
|
36
|
+
.option("--path <folder>", "Explicit station root folder (overrides prometheus mode)")
|
|
37
|
+
.option("--prometheus", "Use prometheus mode")
|
|
38
|
+
.option("--pro", "Alias of --prometheus")
|
|
39
|
+
.option("--prometheus-name <folder>", "Prometheus folder name", "prometheus")
|
|
40
|
+
.option("--max-up <n>", "Max parent hops", (v) => Number(v), 120)
|
|
41
|
+
.option("--exclude <names>", "Comma-separated package names to exclude", "")
|
|
42
|
+
.option("--out <file>", "Write report to file (otherwise prints to stdout)", "")
|
|
43
|
+
.option("--skip-npm-check", "Skip npm registry checks (faster, less accurate)", false)
|
|
44
|
+
.action(async (opts) => {
|
|
45
|
+
const stationRoot = resolveStationRoot({
|
|
46
|
+
path: opts.path,
|
|
47
|
+
prometheus: opts.prometheus,
|
|
48
|
+
pro: opts.pro,
|
|
49
|
+
prometheusName: opts.prometheusName,
|
|
50
|
+
maxUp: opts.maxUp
|
|
51
|
+
});
|
|
52
|
+
const excludePackages = opts.exclude
|
|
53
|
+
? String(opts.exclude).split(",").map(s => s.trim()).filter(Boolean)
|
|
54
|
+
: undefined;
|
|
55
|
+
console.log("Discovering packages...");
|
|
56
|
+
const inv = await discoverStationInventory(stationRoot, excludePackages);
|
|
57
|
+
const graph = buildStationGraph(inv);
|
|
58
|
+
// Filter to publishable, non-private packages
|
|
59
|
+
const publishablePackages = inv.packages.filter(p => !p.private && p.publishable);
|
|
60
|
+
console.log(`Checking ${publishablePackages.length} packages against npm registry...`);
|
|
61
|
+
const statuses = [];
|
|
62
|
+
for (const pkg of publishablePackages) {
|
|
63
|
+
let status = {
|
|
64
|
+
name: pkg.name,
|
|
65
|
+
version: pkg.version,
|
|
66
|
+
localVersion: pkg.version,
|
|
67
|
+
published: false,
|
|
68
|
+
needsPublish: true
|
|
69
|
+
};
|
|
70
|
+
if (!opts.skipNpmCheck) {
|
|
71
|
+
const npmStatus = await checkNpmPackageStatus(pkg.name, pkg.version);
|
|
72
|
+
status.published = npmStatus.published;
|
|
73
|
+
status.latest = npmStatus.latest;
|
|
74
|
+
status.error = npmStatus.error;
|
|
75
|
+
// Needs publish if not published OR local version is newer/different
|
|
76
|
+
if (npmStatus.published && npmStatus.latest) {
|
|
77
|
+
status.needsPublish = pkg.version !== npmStatus.latest;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
status.needsPublish = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Without npm check, assume needs publish
|
|
85
|
+
status.needsPublish = true;
|
|
86
|
+
}
|
|
87
|
+
statuses.push(status);
|
|
88
|
+
}
|
|
89
|
+
// Generate report
|
|
90
|
+
const lines = [];
|
|
91
|
+
lines.push(`# Station Status Report`);
|
|
92
|
+
lines.push(`- Station root: \`${stationRoot}\``);
|
|
93
|
+
lines.push(`- Generated: ${new Date().toISOString()}`);
|
|
94
|
+
lines.push(`- Total packages: **${inv.packages.length}**`);
|
|
95
|
+
lines.push(`- Publishable packages: **${publishablePackages.length}**`);
|
|
96
|
+
lines.push("");
|
|
97
|
+
const published = statuses.filter(s => s.published && !s.needsPublish);
|
|
98
|
+
const needsPublish = statuses.filter(s => s.needsPublish);
|
|
99
|
+
const notPublished = statuses.filter(s => !s.published && s.needsPublish);
|
|
100
|
+
const errors = statuses.filter(s => s.error);
|
|
101
|
+
lines.push(`## Summary`);
|
|
102
|
+
lines.push(`- ✅ Published and up-to-date: **${published.length}**`);
|
|
103
|
+
lines.push(`- 📦 Needs publishing: **${needsPublish.length}**`);
|
|
104
|
+
lines.push(`- ❌ Not published: **${notPublished.length}**`);
|
|
105
|
+
if (errors.length > 0) {
|
|
106
|
+
lines.push(`- ⚠️ Check errors: **${errors.length}**`);
|
|
107
|
+
}
|
|
108
|
+
lines.push("");
|
|
109
|
+
if (needsPublish.length > 0) {
|
|
110
|
+
lines.push(`## 📦 Packages Needing Publication`);
|
|
111
|
+
lines.push("");
|
|
112
|
+
lines.push(`| Package | Local Version | Published Version | Status |`);
|
|
113
|
+
lines.push(`|---|---:|---:|---|`);
|
|
114
|
+
for (const status of needsPublish) {
|
|
115
|
+
const versionInfo = status.published && status.latest
|
|
116
|
+
? `\`${status.latest}\` → \`${status.localVersion}\``
|
|
117
|
+
: status.published
|
|
118
|
+
? `\`${status.latest}\` (unknown)`
|
|
119
|
+
: `Not published`;
|
|
120
|
+
const statusIcon = status.published ? "🔄 Update" : "🆕 New";
|
|
121
|
+
lines.push(`| \`${status.name}\` | \`${status.localVersion}\` | ${versionInfo} | ${statusIcon} |`);
|
|
122
|
+
}
|
|
123
|
+
lines.push("");
|
|
124
|
+
}
|
|
125
|
+
if (published.length > 0) {
|
|
126
|
+
lines.push(`## ✅ Published and Up-to-Date`);
|
|
127
|
+
lines.push("");
|
|
128
|
+
for (const status of published) {
|
|
129
|
+
lines.push(`- \`${status.name}\` @ \`${status.localVersion}\` (published: \`${status.latest}\`)`);
|
|
130
|
+
}
|
|
131
|
+
lines.push("");
|
|
132
|
+
}
|
|
133
|
+
if (errors.length > 0) {
|
|
134
|
+
lines.push(`## ⚠️ Check Errors`);
|
|
135
|
+
lines.push("");
|
|
136
|
+
for (const status of errors) {
|
|
137
|
+
lines.push(`- \`${status.name}\`: ${status.error}`);
|
|
138
|
+
}
|
|
139
|
+
lines.push("");
|
|
140
|
+
}
|
|
141
|
+
if (inv.invalidPackageJson.length > 0) {
|
|
142
|
+
lines.push(`## ❌ Invalid package.json Files`);
|
|
143
|
+
lines.push("");
|
|
144
|
+
for (const invalid of inv.invalidPackageJson) {
|
|
145
|
+
const relPath = path.relative(stationRoot, invalid.path);
|
|
146
|
+
lines.push(`- \`${relPath}\`: ${invalid.error}`);
|
|
147
|
+
}
|
|
148
|
+
lines.push("");
|
|
149
|
+
}
|
|
150
|
+
lines.push(`## Notes`);
|
|
151
|
+
lines.push(`- **Published and up-to-date**: Package exists on npm and local version matches published version.`);
|
|
152
|
+
lines.push(`- **Needs publishing**: Package is not published or local version differs from published version.`);
|
|
153
|
+
lines.push(`- Use \`nx-npm-tools publishStation --pro\` to publish packages that need publishing.`);
|
|
154
|
+
lines.push("");
|
|
155
|
+
const out = lines.join("\n");
|
|
156
|
+
if (opts.out) {
|
|
157
|
+
const outPath = path.resolve(opts.out);
|
|
158
|
+
writeText(outPath, out);
|
|
159
|
+
console.log(`\n✅ Status report written: ${outPath}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
console.log("\n" + out);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=statusStation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusStation.js","sourceRoot":"","sources":["../../src/commands/statusStation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C,KAAK,UAAU,qBAAqB,CAAC,OAAe,EAAE,YAAoB;IACxE,IAAI,CAAC;QACH,kEAAkE;QAClE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACpF,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAE9B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC;QAED,wDAAwD;QACxD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAEhG,OAAO;YACL,SAAS,EAAE,IAAI;YACf,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readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
3
6
|
import { runOnceCommand } from "./commands/runOnce.js";
|
|
4
7
|
import { gitSyncCommand } from "./commands/gitSync.js";
|
|
5
8
|
import { publishOneCommand } from "./commands/publishOne.js";
|
|
@@ -7,11 +10,18 @@ import { publishStationCommand } from "./commands/publishStation.js";
|
|
|
7
10
|
import { reportStationCommand } from "./commands/reportStation.js";
|
|
8
11
|
import { archiveExcludedCommand } from "./commands/archiveExcluded.js";
|
|
9
12
|
import { excludePackagesCommand } from "./commands/excludePackages.js";
|
|
13
|
+
import { statusStationCommand } from "./commands/statusStation.js";
|
|
14
|
+
// Read version from package.json
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
const packageJsonPath = join(__dirname, "..", "package.json");
|
|
18
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
19
|
+
const version = packageJson.version || "0.0.0";
|
|
10
20
|
const program = new Command();
|
|
11
21
|
program
|
|
12
22
|
.name("nx-npm-tools")
|
|
13
23
|
.description("Renovate setup + station scan + dependency graph + ordered npm publishing.")
|
|
14
|
-
.version(
|
|
24
|
+
.version(version);
|
|
15
25
|
program.addCommand(runOnceCommand());
|
|
16
26
|
program.addCommand(gitSyncCommand());
|
|
17
27
|
program.addCommand(publishOneCommand());
|
|
@@ -19,5 +29,6 @@ program.addCommand(publishStationCommand());
|
|
|
19
29
|
program.addCommand(reportStationCommand());
|
|
20
30
|
program.addCommand(archiveExcludedCommand());
|
|
21
31
|
program.addCommand(excludePackagesCommand());
|
|
32
|
+
program.addCommand(statusStationCommand());
|
|
22
33
|
program.parse(process.argv);
|
|
23
34
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":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AG,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;AAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;AACtE,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC;AAE/C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,4EAA4E,CAAC;KACzF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;AACrC,OAAO,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;AACrC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACxC,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAC5C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;AAC3C,OAAO,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAC;AAC7C,OAAO,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAC;AAC7C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;AAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/utils/prometheus.js
CHANGED
|
@@ -1,14 +1,69 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
import { isDir } from "./fs.js";
|
|
2
4
|
export function findAncestorFolderByName(startDir, folderName = "prometheus", maxUp = 120) {
|
|
3
5
|
let cur = path.resolve(startDir);
|
|
6
|
+
// First, try walking up the directory tree
|
|
4
7
|
for (let i = 0; i <= maxUp; i++) {
|
|
5
|
-
if (path.basename(cur) === folderName)
|
|
8
|
+
if (path.basename(cur) === folderName && isDir(cur)) {
|
|
6
9
|
return cur;
|
|
10
|
+
}
|
|
7
11
|
const parent = path.dirname(cur);
|
|
8
12
|
if (parent === cur)
|
|
9
13
|
break;
|
|
10
14
|
cur = parent;
|
|
11
15
|
}
|
|
12
|
-
|
|
16
|
+
// If not found in ancestors, search common locations on disk
|
|
17
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
18
|
+
const commonSearchPaths = [];
|
|
19
|
+
if (homeDir) {
|
|
20
|
+
// Search in home directory and common subdirectories
|
|
21
|
+
commonSearchPaths.push(path.join(homeDir, "**", folderName), path.join(homeDir, "Documents", "**", folderName), path.join(homeDir, "Desktop", "**", folderName), path.join(homeDir, "Projects", "**", folderName));
|
|
22
|
+
}
|
|
23
|
+
// Also try root-level search (but limit depth)
|
|
24
|
+
const rootPath = path.parse(startDir).root;
|
|
25
|
+
if (rootPath) {
|
|
26
|
+
commonSearchPaths.push(path.join(rootPath, "**", folderName));
|
|
27
|
+
}
|
|
28
|
+
// Try to find it in common locations
|
|
29
|
+
for (const searchPath of commonSearchPaths) {
|
|
30
|
+
try {
|
|
31
|
+
const matches = fg.sync([searchPath], {
|
|
32
|
+
onlyDirectories: true,
|
|
33
|
+
caseSensitiveMatch: false,
|
|
34
|
+
followSymbolicLinks: false,
|
|
35
|
+
deep: 5 // Limit depth to avoid searching entire disk
|
|
36
|
+
});
|
|
37
|
+
if (matches.length > 0) {
|
|
38
|
+
// Return the first match that's actually a directory
|
|
39
|
+
for (const match of matches) {
|
|
40
|
+
const resolved = path.resolve(match);
|
|
41
|
+
if (isDir(resolved) && path.basename(resolved).toLowerCase() === folderName.toLowerCase()) {
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Continue to next search path
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// If still not found, provide helpful error message
|
|
53
|
+
const errorMsg = [
|
|
54
|
+
`❌ Prometheus mode: Could not find folder named "${folderName}"`,
|
|
55
|
+
``,
|
|
56
|
+
`Searched:`,
|
|
57
|
+
` 1. Ancestor directories from: ${startDir}`,
|
|
58
|
+
` 2. Common disk locations (home, documents, etc.)`,
|
|
59
|
+
``,
|
|
60
|
+
`Options:`,
|
|
61
|
+
` - Use --path <folder> to specify the station root explicitly`,
|
|
62
|
+
` - Create a folder named "${folderName}" in your project hierarchy`,
|
|
63
|
+
` - Use --prometheus-name <name> to search for a different folder name`,
|
|
64
|
+
``,
|
|
65
|
+
`Current directory: ${startDir}`
|
|
66
|
+
].join("\n");
|
|
67
|
+
throw new Error(errorMsg);
|
|
13
68
|
}
|
|
14
69
|
//# sourceMappingURL=prometheus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prometheus.js","sourceRoot":"","sources":["../../src/utils/prometheus.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"prometheus.js","sourceRoot":"","sources":["../../src/utils/prometheus.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,UAAU,wBAAwB,CACtC,QAAgB,EAChB,UAAU,GAAG,YAAY,EACzB,KAAK,GAAG,GAAG;IAEX,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjC,2CAA2C;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE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