@quark-hq/quark-scripts 0.0.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/LICENSE +21 -0
- package/dist/app/base-application.js +67 -0
- package/dist/app/buildApplication.js +20 -0
- package/dist/app/copyStaticApplication.js +34 -0
- package/dist/app/devApplication.js +59 -0
- package/dist/app/prod-publish-application.js +124 -0
- package/dist/app/publish-dev-application.js +104 -0
- package/dist/app/publishDevApplication.js +16 -0
- package/dist/app/release-application.js +85 -0
- package/dist/app/releaseApplication.js +154 -0
- package/dist/app/unfreeze-application.js +75 -0
- package/dist/app/watchStaticApplication.js +34 -0
- package/dist/cli/cli-containers.js +70 -0
- package/dist/cli/cliCommand.js +2 -0
- package/dist/cli/cliContainers.js +62 -0
- package/dist/cli/commands/buildCommands.js +17 -0
- package/dist/cli/commands/copyStaticCommands.js +17 -0
- package/dist/cli/commands/devCommands.js +17 -0
- package/dist/cli/commands/prod-publish-commands.js +18 -0
- package/dist/cli/commands/publish-dev-commands.js +17 -0
- package/dist/cli/commands/publishDevCommands.js +17 -0
- package/dist/cli/commands/release-commands.js +17 -0
- package/dist/cli/commands/releaseCommands.js +17 -0
- package/dist/cli/commands/relesaeCommand.js +15 -0
- package/dist/cli/commands/unfreeze-commands.js +17 -0
- package/dist/cli/commands/watchStaticCommands.js +17 -0
- package/dist/cli/program.js +16 -0
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.js +132 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/domain/graph.js +2 -0
- package/dist/domain/new-package-freeze-from-map.js +21 -0
- package/dist/domain/resolve-workspace-dependency-specifier-for-freeze-map.js +33 -0
- package/dist/domain/reverse-dependents.js +45 -0
- package/dist/domain/topological-sorting.js +43 -0
- package/dist/domain/transitive-dependents.js +25 -0
- package/dist/domain/workspace-transitive-dependencies.js +25 -0
- package/dist/errors/unfreeze-blocked-error.js +44 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/adapters/base-release-adapter.js +281 -0
- package/dist/infrastructure/adapters/maven-prod-publish-adapter.js +48 -0
- package/dist/infrastructure/adapters/maven-release-adapter.js +58 -0
- package/dist/infrastructure/adapters/node-prod-publish-adapter.js +111 -0
- package/dist/infrastructure/adapters/node-release-adapter/node-file-update.js +1 -0
- package/dist/infrastructure/adapters/node-release-adapter/node-release-adapter.js +289 -0
- package/dist/infrastructure/adapters/node-release-adapter.js +202 -0
- package/dist/infrastructure/config/loadDotEnv.js +38 -0
- package/dist/infrastructure/config/nodeRegistryEnv.js +41 -0
- package/dist/infrastructure/config/quarkConfigProvider.js +50 -0
- package/dist/infrastructure/git/gitService.js +179 -0
- package/dist/infrastructure/graph/nxGraphProvide.js +84 -0
- package/dist/infrastructure/logging/consoleLogger.js +25 -0
- package/dist/infrastructure/process/nodeProcessRunner.js +14 -0
- package/dist/infrastructure/release/git-release-map-store.js +64 -0
- package/dist/ports/config.js +2 -0
- package/dist/ports/git.js +2 -0
- package/dist/ports/graph.js +2 -0
- package/dist/ports/logger.js +2 -0
- package/dist/ports/map.js +2 -0
- package/dist/ports/platform-dev-publish-adapter.js +2 -0
- package/dist/ports/platform-prod-publish-adapter.js +2 -0
- package/dist/ports/platform-release-adapter.js +2 -0
- package/dist/ports/processRunner.js +2 -0
- package/dist/ports/prompts.js +2 -0
- package/dist/ports/release-map-store.js +2 -0
- package/dist/scripts/dev.d.ts +20 -0
- package/dist/scripts/dev.js +204 -0
- package/dist/scripts/dev.js.map +1 -0
- package/dist/scripts/map.json +1616 -0
- package/dist/scripts/prod.d.ts +1 -0
- package/dist/scripts/prod.js +143 -0
- package/dist/scripts/prod.js.map +1 -0
- package/dist/scripts/release.d.ts +51 -0
- package/dist/scripts/release.js +833 -0
- package/dist/scripts/release.js.map +1 -0
- package/dist/tests/index.test.js +13 -0
- package/dist/tests/mocks/release.js +8 -0
- package/dist/tests/unit/release/index.test.js +32 -0
- package/dist/utils/checkIfFreeze.js +1 -0
- package/dist/utils/commit.js +39 -0
- package/dist/utils/drawRepoStatus.js +66 -0
- package/dist/utils/file.js +14 -0
- package/dist/utils/metrics.js +22 -0
- package/package.json +64 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.dev = exports.build = exports.watchStatic = exports.copyStatic = exports.release = exports.publish_dev = void 0;
|
|
7
|
+
exports.safeExec = safeExec;
|
|
8
|
+
const commander_1 = require("commander");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
// Shared configuration - Files/folders to exclude from static assets
|
|
12
|
+
// These patterns are tested and work reliably with copyfiles
|
|
13
|
+
const IGNORE_PATTERNS = [
|
|
14
|
+
'dist/**',
|
|
15
|
+
'node_modules/**',
|
|
16
|
+
'**/*.ts',
|
|
17
|
+
'**/*.tsx',
|
|
18
|
+
'**/*.js',
|
|
19
|
+
'**/*.jsx',
|
|
20
|
+
'**/*.tsbuildinfo',
|
|
21
|
+
'**/tsconfig.json',
|
|
22
|
+
'**/.npmrc',
|
|
23
|
+
'**/package-lock.json'
|
|
24
|
+
];
|
|
25
|
+
function safeExec(command, errorMessage) {
|
|
26
|
+
try {
|
|
27
|
+
(0, child_process_1.execSync)(command, { stdio: "inherit" });
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
console.error(chalk_1.default.red(`❌ ${errorMessage}`));
|
|
31
|
+
if (error instanceof Error) {
|
|
32
|
+
console.error(chalk_1.default.red(error.message));
|
|
33
|
+
}
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.publish_dev = new commander_1.Command("publish:dev")
|
|
38
|
+
.description("Publish a package to the dev registry")
|
|
39
|
+
.action(() => {
|
|
40
|
+
try {
|
|
41
|
+
console.log(chalk_1.default.cyan("📦 Publishing to dev registry..."));
|
|
42
|
+
const publishScript = require("../scripts/dev").default;
|
|
43
|
+
const publish = new publishScript();
|
|
44
|
+
publish.run();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error(chalk_1.default.red("❌ Failed to publish to dev registry"));
|
|
48
|
+
if (error instanceof Error) {
|
|
49
|
+
console.error(chalk_1.default.red(error.message));
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.release = new commander_1.Command("release")
|
|
55
|
+
.description("Create and publish a release")
|
|
56
|
+
.option("-v, --verbose", "Enable verbose logging", false)
|
|
57
|
+
.action((options) => {
|
|
58
|
+
try {
|
|
59
|
+
// console.log(options.verbose,"@@@@@@@@@@@", "🚀")
|
|
60
|
+
if (options.verbose) {
|
|
61
|
+
console.log(chalk_1.default.gray("🔍 Verbose mode enabled"));
|
|
62
|
+
process.env.VERBOSE = "true";
|
|
63
|
+
}
|
|
64
|
+
console.log(chalk_1.default.cyan("🚀 Creating release..."));
|
|
65
|
+
const ReleaseScript = require("../scripts/release").default;
|
|
66
|
+
const release = new ReleaseScript({
|
|
67
|
+
verbose: options.verbose,
|
|
68
|
+
});
|
|
69
|
+
release.run();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error(chalk_1.default.red("❌ Failed to create release"));
|
|
73
|
+
if (error instanceof Error) {
|
|
74
|
+
console.error(chalk_1.default.red(error.message));
|
|
75
|
+
}
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
exports.copyStatic = new commander_1.Command("copy-static")
|
|
80
|
+
.description("Copy static assets to the dist directory")
|
|
81
|
+
.action(() => {
|
|
82
|
+
console.log(chalk_1.default.cyan("📦 Copying static assets..."));
|
|
83
|
+
// Build exclude patterns - use the proven working patterns
|
|
84
|
+
const excludePatterns = IGNORE_PATTERNS.map(p => `--exclude '${p}'`).join(' ');
|
|
85
|
+
// Copy all files to dist/, excluding specified patterns
|
|
86
|
+
const command = `copyfiles '**/*' dist/ ${excludePatterns}`;
|
|
87
|
+
safeExec(command, "Failed to copy static assets");
|
|
88
|
+
console.log(chalk_1.default.green("✅ Static assets copied successfully"));
|
|
89
|
+
});
|
|
90
|
+
exports.watchStatic = new commander_1.Command("watch-static")
|
|
91
|
+
.description("Watch static assets and copy them on changes")
|
|
92
|
+
.action(() => {
|
|
93
|
+
console.log(chalk_1.default.cyan("👀 Watching static assets..."));
|
|
94
|
+
const ignorePatterns = IGNORE_PATTERNS.map(p => `-i '${p}'`).join(' ');
|
|
95
|
+
safeExec(`chokidar '**/*' ${ignorePatterns} -c 'quark-scripts copy-static'`, "Failed to watch static assets");
|
|
96
|
+
});
|
|
97
|
+
exports.build = new commander_1.Command("build")
|
|
98
|
+
.description("Build the package for production")
|
|
99
|
+
.option("--skip-static", "Skip copying static assets")
|
|
100
|
+
.action((options) => {
|
|
101
|
+
console.log(chalk_1.default.cyan("🔨 Building package..."));
|
|
102
|
+
// Step 1: TypeScript compilation
|
|
103
|
+
console.log(chalk_1.default.dim("→ Compiling TypeScript..."));
|
|
104
|
+
safeExec("tsc", "TypeScript compilation failed");
|
|
105
|
+
// Step 2: Copy static assets (unless skipped)
|
|
106
|
+
if (!options.skipStatic) {
|
|
107
|
+
console.log(chalk_1.default.dim("→ Copying static assets..."));
|
|
108
|
+
safeExec("quark-scripts copy-static", "Failed to copy static assets");
|
|
109
|
+
}
|
|
110
|
+
console.log(chalk_1.default.green("✅ Build completed successfully"));
|
|
111
|
+
});
|
|
112
|
+
exports.dev = new commander_1.Command("dev")
|
|
113
|
+
.description("Run development mode with file watching")
|
|
114
|
+
.option("--skip-initial-copy", "Skip initial static assets copy")
|
|
115
|
+
.action((options) => {
|
|
116
|
+
console.log(chalk_1.default.cyan("🚀 Starting development mode..."));
|
|
117
|
+
// Initial copy of static assets (unless skipped)
|
|
118
|
+
if (!options.skipInitialCopy) {
|
|
119
|
+
console.log(chalk_1.default.dim("→ Initial copy of static assets..."));
|
|
120
|
+
try {
|
|
121
|
+
(0, child_process_1.execSync)("quark-scripts copy-static", { stdio: "inherit" });
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error(chalk_1.default.yellow("⚠️ Initial copy failed, continuing anyway..."));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Build watch command
|
|
128
|
+
const ignorePatterns = IGNORE_PATTERNS.map(p => `-i '${p}'`).join(' ');
|
|
129
|
+
const watchCommand = `concurrently --names "TSC,ASSETS" --prefix-colors "cyan,magenta" "tsc --watch --preserveWatchOutput" "chokidar '**/*' ${ignorePatterns} -c 'quark-scripts copy-static'"`;
|
|
130
|
+
console.log(chalk_1.default.dim("→ Starting watchers..."));
|
|
131
|
+
safeExec(watchCommand, "Development mode failed");
|
|
132
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAoC;AAEpC,kDAA0B;AAC1B,iDAAyC;AAEzC,qEAAqE;AACrE,6DAA6D;AAC7D,MAAM,eAAe,GAAG;IACpB,SAAS;IACT,iBAAiB;IACjB,SAAS;IACT,UAAU;IACV,SAAS;IACT,UAAU;IACV,kBAAkB;IAClB,kBAAkB;IAClB,WAAW;IACX,sBAAsB;CACzB,CAAC;AAGF,SAAS,QAAQ,CAAC,OAAe,EAAE,YAAoB;IACnD,IAAI,CAAC;QACD,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC,CAAC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CAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveNewPackageFreezeFromReleaseMap = resolveNewPackageFreezeFromReleaseMap;
|
|
4
|
+
const workspace_transitive_dependencies_1 = require("./workspace-transitive-dependencies");
|
|
5
|
+
/**
|
|
6
|
+
* For a **new** package (not yet in the release map), determines whether it must be
|
|
7
|
+
* treated as frozen because it depends—directly or transitively—on a workspace
|
|
8
|
+
* package that is already marked `frozen` in `.release/map.json`.
|
|
9
|
+
*
|
|
10
|
+
* When `shouldFreeze` is true, the release flow should set `frozen: true` on the
|
|
11
|
+
* new package so {@link NodeReleaseAdapter.writePackageFiles} pins workspace
|
|
12
|
+
* dependency versions and records `pinnedDependencies` on the map entry.
|
|
13
|
+
*/
|
|
14
|
+
function resolveNewPackageFreezeFromReleaseMap(packageName, adjacency, releaseMap) {
|
|
15
|
+
const transitive = (0, workspace_transitive_dependencies_1.collectTransitiveWorkspaceDependencies)(packageName, adjacency);
|
|
16
|
+
const frozenWorkspaceDependencies = transitive.filter((dep) => releaseMap[dep]?.frozen === true);
|
|
17
|
+
return {
|
|
18
|
+
shouldFreeze: frozenWorkspaceDependencies.length > 0,
|
|
19
|
+
frozenWorkspaceDependencies: [...frozenWorkspaceDependencies].sort(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveWorkspaceDependencySpecifierForFreezeMap = resolveWorkspaceDependencySpecifierForFreezeMap;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the semver/range string to write for a workspace dependency when pinning
|
|
6
|
+
* a frozen package's package.json.
|
|
7
|
+
*
|
|
8
|
+
* Prefer versions recorded on **frozen** map entries' `pinnedDependencies` for `depName`
|
|
9
|
+
* (the versions other frozen packages already locked to — e.g. after a major bump, `C`
|
|
10
|
+
* may have `newVersion` `2.0.0` while frozen consumers still pin `C` to `1.x`).
|
|
11
|
+
*
|
|
12
|
+
* If no frozen package pins `depName`, falls back to `packageMap[depName].newVersion`.
|
|
13
|
+
*/
|
|
14
|
+
function resolveWorkspaceDependencySpecifierForFreezeMap(depName, packageMap) {
|
|
15
|
+
const fromFrozenPins = [];
|
|
16
|
+
for (const entry of Object.values(packageMap)) {
|
|
17
|
+
if (entry.frozen !== true || !entry.pinnedDependencies) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const spec = entry.pinnedDependencies[depName];
|
|
21
|
+
if (spec !== undefined) {
|
|
22
|
+
fromFrozenPins.push(spec);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (fromFrozenPins.length > 0) {
|
|
26
|
+
const unique = [...new Set(fromFrozenPins)];
|
|
27
|
+
if (unique.length > 1) {
|
|
28
|
+
throw new Error(`Release map: conflicting pinned versions for workspace dependency "${depName}" among frozen packages: ${unique.join(", ")}.`);
|
|
29
|
+
}
|
|
30
|
+
return unique[0];
|
|
31
|
+
}
|
|
32
|
+
return packageMap[depName]?.newVersion;
|
|
33
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectTransitiveReverseDependents = collectTransitiveReverseDependents;
|
|
4
|
+
exports.collectTransitiveReverseDependentsFromForward = collectTransitiveReverseDependentsFromForward;
|
|
5
|
+
/**
|
|
6
|
+
* All packages that **transitively depend on** `rootPkg` (reverse graph BFS):
|
|
7
|
+
* if `X` has a path of forward edges to `rootPkg`, then `X` is included.
|
|
8
|
+
*/
|
|
9
|
+
function collectTransitiveReverseDependents(inverted, rootPkg) {
|
|
10
|
+
const result = [];
|
|
11
|
+
const inResult = new Set();
|
|
12
|
+
const queue = [...(inverted[rootPkg] ?? [])].sort();
|
|
13
|
+
while (queue.length > 0) {
|
|
14
|
+
const n = queue.shift();
|
|
15
|
+
if (inResult.has(n))
|
|
16
|
+
continue;
|
|
17
|
+
inResult.add(n);
|
|
18
|
+
result.push(n);
|
|
19
|
+
for (const up of [...(inverted[n] ?? [])].sort()) {
|
|
20
|
+
if (!inResult.has(up)) {
|
|
21
|
+
queue.push(up);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Same as {@link collectTransitiveReverseDependents} but with an explicit
|
|
29
|
+
* forward adjacency for tests that do not need the full inverted map.
|
|
30
|
+
*/
|
|
31
|
+
function collectTransitiveReverseDependentsFromForward(adjacency, rootPkg) {
|
|
32
|
+
const inverted = {};
|
|
33
|
+
for (const node of Object.keys(adjacency)) {
|
|
34
|
+
inverted[node] = [];
|
|
35
|
+
}
|
|
36
|
+
for (const [node, deps] of Object.entries(adjacency)) {
|
|
37
|
+
for (const dep of deps) {
|
|
38
|
+
if (!inverted[dep]) {
|
|
39
|
+
inverted[dep] = [];
|
|
40
|
+
}
|
|
41
|
+
inverted[dep].push(node);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return collectTransitiveReverseDependents(inverted, rootPkg);
|
|
45
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TopoSorter = void 0;
|
|
4
|
+
class TopoSorter {
|
|
5
|
+
/**
|
|
6
|
+
* DFS-based topological sort.
|
|
7
|
+
* Only considers edges within the provided node subset.
|
|
8
|
+
*/
|
|
9
|
+
sort(adjacency, nodes) {
|
|
10
|
+
const nodeSet = new Set(nodes);
|
|
11
|
+
const visited = new Set();
|
|
12
|
+
const temp = new Set();
|
|
13
|
+
const result = [];
|
|
14
|
+
const visit = (node) => {
|
|
15
|
+
if (visited.has(node))
|
|
16
|
+
return;
|
|
17
|
+
if (temp.has(node)) {
|
|
18
|
+
throw new Error(`Cycle detected involving ${node}`);
|
|
19
|
+
}
|
|
20
|
+
temp.add(node);
|
|
21
|
+
const neighbors = adjacency[node] || [];
|
|
22
|
+
// deterministic order
|
|
23
|
+
const filteredNeighbors = neighbors
|
|
24
|
+
.filter(n => nodeSet.has(n))
|
|
25
|
+
.sort();
|
|
26
|
+
for (const neighbor of filteredNeighbors) {
|
|
27
|
+
visit(neighbor);
|
|
28
|
+
}
|
|
29
|
+
temp.delete(node);
|
|
30
|
+
visited.add(node);
|
|
31
|
+
result.push(node);
|
|
32
|
+
};
|
|
33
|
+
// deterministic root traversal
|
|
34
|
+
const sortedNodes = [...nodes].sort();
|
|
35
|
+
for (const node of sortedNodes) {
|
|
36
|
+
if (!visited.has(node)) {
|
|
37
|
+
visit(node);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.TopoSorter = TopoSorter;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectTransitiveDependents = collectTransitiveDependents;
|
|
4
|
+
/**
|
|
5
|
+
* Collect every project that transitively consumes `rootPkg`: direct dependents,
|
|
6
|
+
* then dependents of those nodes, using the inverted dependency graph
|
|
7
|
+
* (consumer → [] of projects they depend on is NOT this structure).
|
|
8
|
+
*
|
|
9
|
+
* `invertedAdjacencyList[x]` = project names that **depend on** x (Nx-style).
|
|
10
|
+
*/
|
|
11
|
+
function collectTransitiveDependents(rootPkg, invertedAdjacencyList) {
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
const queue = (invertedAdjacencyList[rootPkg] ?? []).filter((n) => n !== rootPkg);
|
|
14
|
+
while (queue.length > 0) {
|
|
15
|
+
const node = queue.shift();
|
|
16
|
+
if (node === rootPkg || seen.has(node))
|
|
17
|
+
continue;
|
|
18
|
+
seen.add(node);
|
|
19
|
+
for (const next of invertedAdjacencyList[node] ?? []) {
|
|
20
|
+
if (next !== rootPkg && !seen.has(next))
|
|
21
|
+
queue.push(next);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [...seen];
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectTransitiveWorkspaceDependencies = collectTransitiveWorkspaceDependencies;
|
|
4
|
+
/**
|
|
5
|
+
* All workspace packages transitively depended on by `pkg` (walk `adjacency`
|
|
6
|
+
* from `pkg` toward its dependencies). Only includes names that appear as keys
|
|
7
|
+
* in `adjacency` (workspace projects).
|
|
8
|
+
*/
|
|
9
|
+
function collectTransitiveWorkspaceDependencies(pkg, adjacency) {
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
const stack = (adjacency[pkg] ?? []).filter((n) => n !== pkg);
|
|
12
|
+
while (stack.length > 0) {
|
|
13
|
+
const dep = stack.pop();
|
|
14
|
+
if (!(dep in adjacency) || dep === pkg || seen.has(dep)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
seen.add(dep);
|
|
18
|
+
for (const next of adjacency[dep] ?? []) {
|
|
19
|
+
if (next !== pkg && !seen.has(next)) {
|
|
20
|
+
stack.push(next);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [...seen].sort();
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UnfreezeBlockedByFrozenDependenciesError = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when `quark unfreeze` cannot proceed because transitive workspace
|
|
10
|
+
* dependencies are still marked frozen in the release map.
|
|
11
|
+
*/
|
|
12
|
+
class UnfreezeBlockedByFrozenDependenciesError extends Error {
|
|
13
|
+
constructor(requestedPackage, blockingPackages) {
|
|
14
|
+
const pkgs = [...new Set(blockingPackages)].sort();
|
|
15
|
+
const summary = `Cannot unfreeze "${requestedPackage}": frozen workspace dependencies — ${pkgs.join(", ")}.`;
|
|
16
|
+
super(summary);
|
|
17
|
+
this.name = "UnfreezeBlockedByFrozenDependenciesError";
|
|
18
|
+
this.requestedPackage = requestedPackage;
|
|
19
|
+
this.blockingPackages = pkgs;
|
|
20
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
21
|
+
}
|
|
22
|
+
/** Rich multi-line output for the CLI (used from the process entrypoint). */
|
|
23
|
+
renderCli() {
|
|
24
|
+
const bullets = this.blockingPackages
|
|
25
|
+
.map((p) => ` ${chalk_1.default.yellow("•")} ${chalk_1.default.white(p)}`)
|
|
26
|
+
.join("\n");
|
|
27
|
+
return [
|
|
28
|
+
"",
|
|
29
|
+
chalk_1.default.red.bold("Unfreeze blocked"),
|
|
30
|
+
"",
|
|
31
|
+
chalk_1.default.red(this.message),
|
|
32
|
+
"",
|
|
33
|
+
chalk_1.default.gray("This package still has workspace dependencies that are frozen in .release/map.json."),
|
|
34
|
+
chalk_1.default.gray("Unfreeze from the bottom of the graph upward (leaf libs first), then middle layers, then apps."),
|
|
35
|
+
"",
|
|
36
|
+
chalk_1.default.bold("Still frozen (resolve these first):"),
|
|
37
|
+
bullets,
|
|
38
|
+
"",
|
|
39
|
+
chalk_1.default.dim("Example: for A → B → C, run `quark unfreeze C`, then `quark unfreeze B`, then `quark unfreeze A`."),
|
|
40
|
+
"",
|
|
41
|
+
].join("\n");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.UnfreezeBlockedByFrozenDependenciesError = UnfreezeBlockedByFrozenDependenciesError;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
|
+
const program_1 = require("./cli/program");
|
|
10
|
+
const quark_security_1 = require("@quark-hq/quark-security");
|
|
11
|
+
const unfreeze_blocked_error_1 = require("./errors/unfreeze-blocked-error");
|
|
12
|
+
dotenv_1.default.config({
|
|
13
|
+
path: path_1.default.resolve(process.cwd(), ".env"),
|
|
14
|
+
});
|
|
15
|
+
async function bootstrap() {
|
|
16
|
+
try {
|
|
17
|
+
const program = (0, program_1.createProgram)();
|
|
18
|
+
await program.parseAsync(process.argv);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof unfreeze_blocked_error_1.UnfreezeBlockedByFrozenDependenciesError) {
|
|
22
|
+
console.error(error.renderCli());
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
console.error("Fatal error:", (0, quark_security_1.formatErrorMessage)(error));
|
|
26
|
+
if ((0, quark_security_1.shouldLogErrorStack)() && error instanceof Error && error.stack) {
|
|
27
|
+
console.error(error.stack);
|
|
28
|
+
}
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
bootstrap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,4CAA2G;AAE3G,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,OAAO,CAAC,OAAO,CAAC;KAChB,UAAU,CAAC,mBAAW,CAAC;KACvB,UAAU,CAAC,oBAAY,CAAC;KACxB,UAAU,CAAC,eAAO,CAAC;KACnB,UAAU,CAAC,kBAAU,CAAC;KACtB,UAAU,CAAC,mBAAW,CAAC;KACvB,UAAU,CAAC,aAAK,CAAC;KACjB,UAAU,CAAC,WAAG,CAAC,CAAA;AAElB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|