@webquark/core 1.1.0-dev.9 → 1.1.1-dev.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/dist/browser/components/q-control-group.d.ts +1 -0
- package/dist/browser/components/q-control-group.js +1 -0
- package/dist/browser/components/q-divider.d.ts +1 -0
- package/dist/browser/components/q-divider.js +1 -0
- package/dist/browser/components/q-slider.d.ts +1 -0
- package/dist/browser/components/q-slider.js +1 -0
- package/dist/browser/components/q-syntax-view.d.ts +1 -0
- package/dist/browser/components/q-syntax-view.js +1 -0
- package/dist/browser/webquark.css +1 -1
- package/dist/playground/assets/reel-motion.webm +0 -0
- package/dist/playground/build/p-014c2f4a.entry.js +1 -0
- package/dist/playground/build/p-0389577c.entry.js +1 -0
- package/dist/playground/build/p-041e17c1.entry.js +1 -0
- package/dist/playground/build/p-0479c571.entry.js +1 -0
- package/dist/playground/build/p-0ebca9be.entry.js +1 -0
- package/dist/playground/build/{p-fe8c634a.entry.js → p-1bf375f7.entry.js} +2 -2
- package/dist/playground/build/{p-6bfffa79.entry.js → p-20dc3ab5.entry.js} +1 -1
- package/dist/playground/build/p-28d3348f.entry.js +1 -0
- package/dist/playground/build/p-35c177d3.entry.js +1 -0
- package/dist/playground/build/{p-99d785ca.entry.js → p-3a60086d.entry.js} +1 -1
- package/dist/playground/build/{p-3bc4629c.entry.js → p-3ab798aa.entry.js} +1 -1
- package/dist/playground/build/{p-9e78b796.entry.js → p-3b580baf.entry.js} +1 -1
- package/dist/playground/build/{p-888e46a8.entry.js → p-3b65f787.entry.js} +1 -1
- package/dist/playground/build/p-45f6e9ec.css +1 -0
- package/dist/playground/build/p-4bf610f8.entry.js +1 -0
- package/dist/playground/build/{p-4d61b70d.entry.js → p-4d30227e.entry.js} +1 -1
- package/dist/playground/build/{p-70d9ffde.entry.js → p-4de536ae.entry.js} +1 -1
- package/dist/playground/build/{p-90b0858c.entry.js → p-4e4d70c9.entry.js} +1 -1
- package/dist/playground/build/p-4efeb7c9.entry.js +1 -0
- package/dist/playground/build/{p-dd115868.entry.js → p-51b3d71b.entry.js} +1 -1
- package/dist/playground/build/p-778b6bbb.entry.js +1 -0
- package/dist/playground/build/{p-f63b7214.entry.js → p-7da78b2f.entry.js} +1 -1
- package/dist/playground/build/{p-9ff7e5a4.entry.js → p-7f8f986b.entry.js} +1 -1
- package/dist/playground/build/p-8253c742.entry.js +1 -0
- package/dist/playground/build/{p-059daa8a.entry.js → p-9a1ddeb7.entry.js} +1 -1
- package/dist/playground/build/p-B610wOGe.js +1 -0
- package/dist/playground/build/p-BxxU73QQ.js +1 -0
- package/dist/playground/build/p-CIMzZPQO.js +3 -0
- package/dist/playground/build/p-CfR85WgM.js +13 -0
- package/dist/playground/build/{p-Dhsn99q4.js → p-D8p28N9s.js} +1 -1
- package/dist/playground/build/p-DbzjRzhu.js +1 -0
- package/dist/playground/build/{p-BOdNg0jc.js → p-DeOEN0si.js} +1 -1
- package/dist/playground/build/{p-d0fbd2b1.entry.js → p-a2b1de23.entry.js} +1 -1
- package/dist/playground/build/{p-48fb5228.entry.js → p-a55edc17.entry.js} +1 -1
- package/dist/playground/build/p-a8808020.entry.js +1 -0
- package/dist/playground/build/{p-f4f97e74.entry.js → p-b1084b3c.entry.js} +1 -1
- package/dist/playground/build/{p-36118d90.entry.js → p-b6c4dff4.entry.js} +1 -1
- package/dist/playground/build/p-b962e950.entry.js +1 -0
- package/dist/playground/build/{p-023f8437.entry.js → p-bc369cd6.entry.js} +1 -1
- package/dist/playground/build/p-c119a8ea.entry.js +1 -0
- package/dist/playground/build/p-c6b77e9a.entry.js +1 -0
- package/dist/playground/build/{p-030ecde3.entry.js → p-ca1c03b4.entry.js} +1 -1
- package/dist/playground/build/{p-8ece2c62.entry.js → p-ce436162.entry.js} +1 -1
- package/dist/playground/build/{p-0aa74ad6.entry.js → p-d0a47a7c.entry.js} +1 -1
- package/dist/playground/build/{p-fec6fe0a.entry.js → p-e1fbc8fc.entry.js} +1 -1
- package/dist/playground/build/{p-09cca7b9.entry.js → p-e32833ce.entry.js} +1 -1
- package/dist/playground/build/p-e369a4aa.entry.js +1 -0
- package/dist/playground/build/p-e4430c61.entry.js +1 -0
- package/dist/playground/build/{p-f9ad63ff.entry.js → p-e9c0052b.entry.js} +1 -1
- package/dist/playground/build/{p-f1bac94c.entry.js → p-f5c4ca18.entry.js} +1 -1
- package/dist/playground/build/{p-64096386.entry.js → p-f6683126.entry.js} +1 -1
- package/dist/playground/build/{p-DWO-pleQ.js → p-ojSDiptZ.js} +1 -1
- package/dist/playground/build/webquark.css +1 -1
- package/dist/playground/build/webquark.esm.js +1 -1
- package/dist/playground/css/base.css +17 -44
- package/dist/playground/formatters/prettier/LICENSE +7 -0
- package/dist/playground/formatters/prettier/THIRD-PARTY-NOTICES.md +7941 -0
- package/dist/playground/formatters/prettier/html-fragment.mjs +1 -0
- package/dist/playground/formatters/prettier/html-fragment.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/angular.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/angular.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/css.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/css.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/flow.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/flow.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/graphql.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/graphql.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/handlebars.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/handlebars.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/html.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/html.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/javascript.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/javascript.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/json-stringify.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/json-stringify.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/json.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/json.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/json5.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/json5.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/jsonc.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/jsonc.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/jsx.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/jsx.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/less.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/less.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/lwc.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/lwc.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/markdown.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/markdown.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/mdx.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/mdx.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/mjml.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/mjml.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/postcss.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/postcss.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/scss.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/scss.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/tsx.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/tsx.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/typescript.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/typescript.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/vue.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/vue.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/languages/yaml.mjs +1 -0
- package/dist/playground/formatters/prettier/languages/yaml.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/manifest.json +87 -0
- package/dist/playground/formatters/prettier/plugins/acorn.mjs +17 -0
- package/dist/playground/formatters/prettier/plugins/acorn.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/angular.mjs +7 -0
- package/dist/playground/formatters/prettier/plugins/angular.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/babel.mjs +16 -0
- package/dist/playground/formatters/prettier/plugins/babel.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/estree.mjs +44 -0
- package/dist/playground/formatters/prettier/plugins/estree.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/flow.mjs +7 -0
- package/dist/playground/formatters/prettier/plugins/flow.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/glimmer.mjs +37 -0
- package/dist/playground/formatters/prettier/plugins/glimmer.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/graphql.mjs +17 -0
- package/dist/playground/formatters/prettier/plugins/graphql.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/html.mjs +25 -0
- package/dist/playground/formatters/prettier/plugins/html.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/markdown.mjs +70 -0
- package/dist/playground/formatters/prettier/plugins/markdown.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/meriyah.mjs +9 -0
- package/dist/playground/formatters/prettier/plugins/meriyah.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/postcss.mjs +62 -0
- package/dist/playground/formatters/prettier/plugins/postcss.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/typescript.mjs +22 -0
- package/dist/playground/formatters/prettier/plugins/typescript.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/plugins/yaml.mjs +150 -0
- package/dist/playground/formatters/prettier/plugins/yaml.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/runtime.d.mts +2 -0
- package/dist/playground/formatters/prettier/runtime.mjs +1 -0
- package/dist/playground/formatters/prettier/runtime.mjs.gz +0 -0
- package/dist/playground/formatters/prettier/standalone.mjs +29 -0
- package/dist/playground/formatters/prettier/standalone.mjs.gz +0 -0
- package/dist/playground/index.html +1 -1
- package/dist/playground/playground/components.manifest.json +54 -41
- package/dist/playground/playground/consumer.html +27 -0
- package/dist/playground/playground/specs/q-accordion.sandbox.json +38 -0
- package/dist/playground/playground/specs/q-alert.sandbox.json +95 -0
- package/dist/playground/playground/specs/q-avatar.sandbox.json +39 -6
- package/dist/playground/playground/specs/q-banner.sandbox.json +66 -0
- package/dist/playground/playground/specs/q-button.sandbox.json +115 -15
- package/dist/playground/playground/specs/q-card.sandbox.json +50 -9
- package/dist/playground/playground/specs/q-carousel.sandbox.json +109 -6
- package/dist/playground/playground/specs/q-chip.sandbox.json +29 -2
- package/dist/playground/playground/specs/q-control-group.sandbox.json +30 -0
- package/dist/playground/playground/specs/q-conversation-bubble.sandbox.json +13 -2
- package/dist/playground/playground/specs/q-data-table.sandbox.json +137 -12
- package/dist/playground/playground/specs/q-dialog.sandbox.json +62 -5
- package/dist/playground/playground/specs/q-divider.sandbox.json +20 -0
- package/dist/playground/playground/specs/q-dropdown.sandbox.json +186 -22
- package/dist/playground/playground/specs/q-form.sandbox.json +66 -1
- package/dist/playground/playground/specs/q-grid.sandbox.json +37 -1
- package/dist/playground/playground/specs/q-icon.sandbox.json +62 -23
- package/dist/playground/playground/specs/q-image-comparison.sandbox.json +41 -5
- package/dist/playground/playground/specs/q-inline.sandbox.json +41 -0
- package/dist/playground/playground/specs/q-input.sandbox.json +77 -5
- package/dist/playground/playground/specs/q-link.sandbox.json +213 -17
- package/dist/playground/playground/specs/q-map.sandbox.json +434 -28
- package/dist/playground/playground/specs/q-media.sandbox.json +85 -0
- package/dist/playground/playground/specs/q-navbar.sandbox.json +378 -29
- package/dist/playground/playground/specs/q-pagination.sandbox.json +89 -0
- package/dist/playground/playground/specs/q-panel.sandbox.json +63 -2
- package/dist/playground/playground/specs/q-progress.sandbox.json +37 -11
- package/dist/playground/playground/specs/q-quantity-selector.sandbox.json +15 -3
- package/dist/playground/playground/specs/q-radio-group.sandbox.json +94 -14
- package/dist/playground/playground/specs/q-reel.sandbox.json +22 -5
- package/dist/playground/playground/specs/q-scrollable.sandbox.json +16 -0
- package/dist/playground/playground/specs/q-section.sandbox.json +69 -0
- package/dist/playground/playground/specs/q-sidepanel.sandbox.json +271 -12
- package/dist/playground/playground/specs/q-slider.sandbox.json +104 -0
- package/dist/playground/playground/specs/q-stack.sandbox.json +13 -2
- package/dist/playground/playground/specs/q-step-diagram-item.sandbox.json +101 -0
- package/dist/playground/playground/specs/q-step-diagram.sandbox.json +29 -1
- package/dist/playground/playground/specs/q-syntax-box.sandbox.json +85 -8
- package/dist/playground/playground/specs/q-syntax-view.sandbox.json +45 -0
- package/dist/playground/playground/specs/q-tabs.sandbox.json +164 -0
- package/dist/playground/playground/specs/q-textarea.sandbox.json +50 -0
- package/dist/playground/playground/specs/q-thumbnail.sandbox.json +67 -0
- package/dist/playground/playground/specs/q-toast.sandbox.json +19 -8
- package/dist/playground/playground/specs/q-toggle.sandbox.json +22 -2
- package/dist/playground/playground/specs/q-toolbar.sandbox.json +55 -0
- package/dist/playground/playground/specs/q-tooltip.sandbox.json +18 -2
- package/dist/playground/playground.js +3986 -2002
- package/dist/playground/presets.html +70 -15
- package/dist/playground/views/tooling/tooling.html +5 -5
- package/package.json +4 -4
- package/scripts/webquark-serve.js +3 -82
- package/scripts/wq-changelog.js +0 -0
- package/scripts/wq-switch/README.md +52 -15
- package/scripts/wq-switch/dist/index.js +1 -1200
- package/scripts/wq-switch/dist/setup.js +1 -894
- package/dist/playground/build/p-04c8cb9e.entry.js +0 -1
- package/dist/playground/build/p-0ae43d6c.entry.js +0 -1
- package/dist/playground/build/p-0c3aac3f.entry.js +0 -1
- package/dist/playground/build/p-144ef339.entry.js +0 -1
- package/dist/playground/build/p-296fbdb1.entry.js +0 -1
- package/dist/playground/build/p-5f232b44.entry.js +0 -13
- package/dist/playground/build/p-6e28cfe2.entry.js +0 -1
- package/dist/playground/build/p-91fff6b6.entry.js +0 -1
- package/dist/playground/build/p-923dac41.entry.js +0 -1
- package/dist/playground/build/p-97a89cae.entry.js +0 -1
- package/dist/playground/build/p-B4Mg1xEw.js +0 -1
- package/dist/playground/build/p-B5ElFlHv.js +0 -3
- package/dist/playground/build/p-Bj2RJb2E.js +0 -1
- package/dist/playground/build/p-ByfrUWx1.js +0 -1
- package/dist/playground/build/p-c523ec6f.entry.js +0 -1
- package/dist/playground/build/p-c923c9c0.js +0 -1
- package/dist/playground/build/p-d0253d64.entry.js +0 -1
- package/dist/playground/build/p-e0bb74ae.css +0 -1
- package/dist/playground/build/p-f98f9439.entry.js +0 -1
- package/dist/playground/build/p-fe200f68.entry.js +0 -1
- package/dist/playground/views/tooling/adoption/CHANGELOG.md +0 -13
- package/dist/playground/views/tooling/adoption/README.md +0 -47
- package/dist/playground/views/tooling/adoption/changelog.config.ts +0 -12
- package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/README.md +0 -3
- package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/images/release-panel.svg +0 -7
- package/dist/playground/views/tooling/adoption/docs/changelog/unreleased/visuals.json +0 -16
- package/dist/playground/views/tooling/adoption/docs/changelog/v0.1.0/README.md +0 -3
- package/dist/playground/views/tooling/adoption/generate.ts +0 -13
- package/dist/playground/views/tooling/adoption/package.json +0 -10
- package/dist/playground/views/tooling/adoption/serve.ts +0 -24
- package/dist/playground/views/tooling/adoption/viewer.html +0 -16
- package/dist/playground/views/tooling/adoption/viewer.js +0 -54
|
@@ -1,1201 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
function __accessProp(key) {
|
|
8
|
-
return this[key];
|
|
9
|
-
}
|
|
10
|
-
var __toESMCache_node;
|
|
11
|
-
var __toESMCache_esm;
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
-
var canCache = mod != null && typeof mod === "object";
|
|
14
|
-
if (canCache) {
|
|
15
|
-
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
-
var cached = cache.get(mod);
|
|
17
|
-
if (cached)
|
|
18
|
-
return cached;
|
|
19
|
-
}
|
|
20
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
-
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(mod))
|
|
24
|
-
if (!__hasOwnProp.call(to, key))
|
|
25
|
-
__defProp(to, key, {
|
|
26
|
-
get: __accessProp.bind(mod, key),
|
|
27
|
-
enumerable: true
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (canCache)
|
|
31
|
-
cache.set(mod, to);
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
35
|
-
|
|
36
|
-
// node_modules/.bun/cmd-shim@8.0.0/node_modules/cmd-shim/lib/to-batch-syntax.js
|
|
37
|
-
var require_to_batch_syntax = __commonJS(function(exports2) {
|
|
38
|
-
exports2.replaceDollarWithPercentPair = replaceDollarWithPercentPair;
|
|
39
|
-
exports2.convertToSetCommand = convertToSetCommand;
|
|
40
|
-
exports2.convertToSetCommands = convertToSetCommands;
|
|
41
|
-
function convertToSetCommand(key, value) {
|
|
42
|
-
var line = "";
|
|
43
|
-
key = key || "";
|
|
44
|
-
key = key.trim();
|
|
45
|
-
value = value || "";
|
|
46
|
-
value = value.trim();
|
|
47
|
-
if (key && value && value.length > 0) {
|
|
48
|
-
line = "@SET " + key + "=" + replaceDollarWithPercentPair(value) + `\r
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
51
|
-
return line;
|
|
52
|
-
}
|
|
53
|
-
function extractVariableValuePairs(declarations) {
|
|
54
|
-
var pairs = {};
|
|
55
|
-
declarations.map(function(declaration) {
|
|
56
|
-
var split = declaration.split("=");
|
|
57
|
-
pairs[split[0]] = split[1];
|
|
58
|
-
});
|
|
59
|
-
return pairs;
|
|
60
|
-
}
|
|
61
|
-
function convertToSetCommands(variableString) {
|
|
62
|
-
var variableValuePairs = extractVariableValuePairs(variableString.split(" "));
|
|
63
|
-
var variableDeclarationsAsBatch = "";
|
|
64
|
-
Object.keys(variableValuePairs).forEach(function(key) {
|
|
65
|
-
variableDeclarationsAsBatch += convertToSetCommand(key, variableValuePairs[key]);
|
|
66
|
-
});
|
|
67
|
-
return variableDeclarationsAsBatch;
|
|
68
|
-
}
|
|
69
|
-
function replaceDollarWithPercentPair(value) {
|
|
70
|
-
var dollarExpressions = /\$\{?([^$@#?\- \t{}:]+)\}?/g;
|
|
71
|
-
var result = "";
|
|
72
|
-
var startIndex = 0;
|
|
73
|
-
do {
|
|
74
|
-
var match = dollarExpressions.exec(value);
|
|
75
|
-
if (match) {
|
|
76
|
-
var betweenMatches = value.substring(startIndex, match.index) || "";
|
|
77
|
-
result += betweenMatches + "%" + match[1] + "%";
|
|
78
|
-
startIndex = dollarExpressions.lastIndex;
|
|
79
|
-
}
|
|
80
|
-
} while (dollarExpressions.lastIndex > 0);
|
|
81
|
-
result += value.slice(startIndex);
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// node_modules/.bun/cmd-shim@8.0.0/node_modules/cmd-shim/lib/index.js
|
|
87
|
-
var require_lib = __commonJS(function(exports2, module2) {
|
|
88
|
-
var {
|
|
89
|
-
chmod,
|
|
90
|
-
mkdir,
|
|
91
|
-
readFile,
|
|
92
|
-
stat,
|
|
93
|
-
unlink,
|
|
94
|
-
writeFile
|
|
95
|
-
} = require("fs/promises");
|
|
96
|
-
var { dirname, relative } = require("path");
|
|
97
|
-
var toBatchSyntax = require_to_batch_syntax();
|
|
98
|
-
var shebangExpr = /^#!\s*(?:\/usr\/bin\/env\s+(?:-S\s+)?((?:[^ \t=]+=[^ \t=]+\s+)*))?([^ \t]+)(.*)$/;
|
|
99
|
-
var cmdShimIfExists = (from, to) => stat(from).then(() => cmdShim(from, to), () => {});
|
|
100
|
-
var rm = (path) => unlink(path).catch(() => {});
|
|
101
|
-
var cmdShim = (from, to) => stat(from).then(() => cmdShim_(from, to));
|
|
102
|
-
var cmdShim_ = (from, to) => Promise.all([
|
|
103
|
-
rm(to),
|
|
104
|
-
rm(to + ".cmd"),
|
|
105
|
-
rm(to + ".ps1")
|
|
106
|
-
]).then(() => writeShim(from, to));
|
|
107
|
-
var writeShim = (from, to) => mkdir(dirname(to), { recursive: true }).then(() => readFile(from, "utf8")).then((data) => {
|
|
108
|
-
const firstLine = data.trim().split(/\r*\n/)[0];
|
|
109
|
-
const shebang = firstLine.match(shebangExpr);
|
|
110
|
-
if (!shebang) {
|
|
111
|
-
return writeShim_(from, to);
|
|
112
|
-
}
|
|
113
|
-
const vars = shebang[1] || "";
|
|
114
|
-
const prog = shebang[2];
|
|
115
|
-
const args = shebang[3] || "";
|
|
116
|
-
return writeShim_(from, to, prog, args, vars);
|
|
117
|
-
}, () => writeShim_(from, to));
|
|
118
|
-
var writeShim_ = (from, to, prog, args, variables) => {
|
|
119
|
-
let shTarget = relative(dirname(to), from);
|
|
120
|
-
let target = shTarget.split("/").join("\\");
|
|
121
|
-
let longProg;
|
|
122
|
-
let shProg = prog && prog.split("\\").join("/");
|
|
123
|
-
let shLongProg;
|
|
124
|
-
let pwshProg = shProg && `"${shProg}$exe"`;
|
|
125
|
-
let pwshLongProg;
|
|
126
|
-
shTarget = shTarget.split("\\").join("/");
|
|
127
|
-
args = args || "";
|
|
128
|
-
variables = variables || "";
|
|
129
|
-
if (!prog) {
|
|
130
|
-
prog = `"%dp0%\\${target}"`;
|
|
131
|
-
shProg = `"$basedir/${shTarget}"`;
|
|
132
|
-
pwshProg = shProg;
|
|
133
|
-
args = "";
|
|
134
|
-
target = "";
|
|
135
|
-
shTarget = "";
|
|
136
|
-
} else {
|
|
137
|
-
longProg = `"%dp0%\\${prog}.exe"`;
|
|
138
|
-
shLongProg = `"$basedir/${prog}"`;
|
|
139
|
-
pwshLongProg = `"$basedir/${prog}$exe"`;
|
|
140
|
-
target = `"%dp0%\\${target}"`;
|
|
141
|
-
shTarget = `"$basedir/${shTarget}"`;
|
|
142
|
-
}
|
|
143
|
-
const head = `@ECHO off\r
|
|
144
|
-
` + `GOTO start\r
|
|
145
|
-
` + `:find_dp0\r
|
|
146
|
-
` + `SET dp0=%~dp0\r
|
|
147
|
-
` + `EXIT /b\r
|
|
148
|
-
` + `:start\r
|
|
149
|
-
` + `SETLOCAL\r
|
|
150
|
-
` + `CALL :find_dp0\r
|
|
151
|
-
`;
|
|
152
|
-
let cmd;
|
|
153
|
-
if (longProg) {
|
|
154
|
-
shLongProg = shLongProg.trim();
|
|
155
|
-
args = args.trim();
|
|
156
|
-
const variablesBatch = toBatchSyntax.convertToSetCommands(variables);
|
|
157
|
-
cmd = head + variablesBatch + `\r
|
|
158
|
-
` + `IF EXIST ${longProg} (\r
|
|
159
|
-
` + ` SET "_prog=${longProg.replace(/(^")|("$)/g, "")}"\r
|
|
160
|
-
` + `) ELSE (\r
|
|
161
|
-
` + ` SET "_prog=${prog.replace(/(^")|("$)/g, "")}"\r
|
|
162
|
-
` + ` SET PATHEXT=%PATHEXT:;.JS;=;%\r
|
|
163
|
-
` + `)\r
|
|
164
|
-
` + `\r
|
|
165
|
-
` + "endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & " + `"%_prog%" ${args} ${target} %*\r
|
|
166
|
-
`;
|
|
167
|
-
} else {
|
|
168
|
-
cmd = `${head}${prog} ${args} ${target} %*\r
|
|
169
|
-
`;
|
|
170
|
-
}
|
|
171
|
-
let sh = `#!/bin/sh
|
|
172
|
-
`;
|
|
173
|
-
sh = sh + `basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
|
|
174
|
-
` + `
|
|
175
|
-
` + "case `uname` in\n" + ` *CYGWIN*|*MINGW*|*MSYS*)
|
|
176
|
-
` + ` if command -v cygpath > /dev/null 2>&1; then
|
|
177
|
-
` + ' basedir=`cygpath -w "$basedir"`\n' + ` fi
|
|
178
|
-
` + ` ;;
|
|
179
|
-
` + `esac
|
|
180
|
-
` + `
|
|
181
|
-
`;
|
|
182
|
-
if (shLongProg) {
|
|
183
|
-
sh = sh + `if [ -x ${shLongProg} ]; then
|
|
184
|
-
` + ` exec ${variables}${shLongProg} ${args} ${shTarget} "$@"
|
|
185
|
-
` + `else
|
|
186
|
-
` + ` exec ${variables}${shProg} ${args} ${shTarget} "$@"
|
|
187
|
-
` + `fi
|
|
188
|
-
`;
|
|
189
|
-
} else {
|
|
190
|
-
sh = sh + `exec ${shProg} ${args} ${shTarget} "$@"
|
|
191
|
-
`;
|
|
192
|
-
}
|
|
193
|
-
let pwsh = `#!/usr/bin/env pwsh
|
|
194
|
-
` + `$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
195
|
-
` + `
|
|
196
|
-
` + `$exe=""
|
|
197
|
-
` + `if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
198
|
-
` + ` # Fix case when both the Windows and Linux builds of Node
|
|
199
|
-
` + ` # are installed in the same directory
|
|
200
|
-
` + ` $exe=".exe"
|
|
201
|
-
` + `}
|
|
202
|
-
`;
|
|
203
|
-
if (shLongProg) {
|
|
204
|
-
pwsh = pwsh + `$ret=0
|
|
205
|
-
` + `if (Test-Path ${pwshLongProg}) {
|
|
206
|
-
` + ` # Support pipeline input
|
|
207
|
-
` + ` if ($MyInvocation.ExpectingInput) {
|
|
208
|
-
` + ` $input | & ${pwshLongProg} ${args} ${shTarget} $args
|
|
209
|
-
` + ` } else {
|
|
210
|
-
` + ` & ${pwshLongProg} ${args} ${shTarget} $args
|
|
211
|
-
` + ` }
|
|
212
|
-
` + ` $ret=$LASTEXITCODE
|
|
213
|
-
` + `} else {
|
|
214
|
-
` + ` # Support pipeline input
|
|
215
|
-
` + ` if ($MyInvocation.ExpectingInput) {
|
|
216
|
-
` + ` $input | & ${pwshProg} ${args} ${shTarget} $args
|
|
217
|
-
` + ` } else {
|
|
218
|
-
` + ` & ${pwshProg} ${args} ${shTarget} $args
|
|
219
|
-
` + ` }
|
|
220
|
-
` + ` $ret=$LASTEXITCODE
|
|
221
|
-
` + `}
|
|
222
|
-
` + `exit $ret
|
|
223
|
-
`;
|
|
224
|
-
} else {
|
|
225
|
-
pwsh = pwsh + `# Support pipeline input
|
|
226
|
-
` + `if ($MyInvocation.ExpectingInput) {
|
|
227
|
-
` + ` $input | & ${pwshProg} ${args} ${shTarget} $args
|
|
228
|
-
` + `} else {
|
|
229
|
-
` + ` & ${pwshProg} ${args} ${shTarget} $args
|
|
230
|
-
` + `}
|
|
231
|
-
` + `exit $LASTEXITCODE
|
|
232
|
-
`;
|
|
233
|
-
}
|
|
234
|
-
return Promise.all([
|
|
235
|
-
writeFile(to + ".ps1", pwsh, "utf8"),
|
|
236
|
-
writeFile(to + ".cmd", cmd, "utf8"),
|
|
237
|
-
writeFile(to, sh, "utf8")
|
|
238
|
-
]).then(() => chmodShim(to));
|
|
239
|
-
};
|
|
240
|
-
var chmodShim = (to) => Promise.all([
|
|
241
|
-
chmod(to, 493),
|
|
242
|
-
chmod(to + ".cmd", 493),
|
|
243
|
-
chmod(to + ".ps1", 493)
|
|
244
|
-
]);
|
|
245
|
-
module2.exports = cmdShim;
|
|
246
|
-
cmdShim.ifExists = cmdShimIfExists;
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// node_modules/.bun/read-cmd-shim@6.0.0/node_modules/read-cmd-shim/lib/index.js
|
|
250
|
-
var require_lib2 = __commonJS(function(exports2, module2) {
|
|
251
|
-
var fs = require("fs");
|
|
252
|
-
var { promisify } = require("util");
|
|
253
|
-
var { readFileSync } = fs;
|
|
254
|
-
var readFile = promisify(fs.readFile);
|
|
255
|
-
var extractPath = (path, cmdshimContents) => {
|
|
256
|
-
if (/[.]cmd$/.test(path)) {
|
|
257
|
-
return extractPathFromCmd(cmdshimContents);
|
|
258
|
-
} else if (/[.]ps1$/.test(path)) {
|
|
259
|
-
return extractPathFromPowershell(cmdshimContents);
|
|
260
|
-
} else {
|
|
261
|
-
return extractPathFromCygwin(cmdshimContents);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
var extractPathFromPowershell = (cmdshimContents) => {
|
|
265
|
-
const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+[$]args/);
|
|
266
|
-
return matches && matches[1];
|
|
267
|
-
};
|
|
268
|
-
var extractPathFromCmd = (cmdshimContents) => {
|
|
269
|
-
const matches = cmdshimContents.match(/"%(?:~dp0|dp0%)\\([^"]+?)"\s+%[*]/);
|
|
270
|
-
return matches && matches[1];
|
|
271
|
-
};
|
|
272
|
-
var extractPathFromCygwin = (cmdshimContents) => {
|
|
273
|
-
const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/);
|
|
274
|
-
return matches && matches[1];
|
|
275
|
-
};
|
|
276
|
-
var wrapError = (thrown, newError) => {
|
|
277
|
-
newError.message = thrown.message;
|
|
278
|
-
newError.code = thrown.code;
|
|
279
|
-
newError.path = thrown.path;
|
|
280
|
-
return newError;
|
|
281
|
-
};
|
|
282
|
-
var notaShim = (path, er) => {
|
|
283
|
-
if (!er) {
|
|
284
|
-
er = new Error;
|
|
285
|
-
Error.captureStackTrace(er, notaShim);
|
|
286
|
-
}
|
|
287
|
-
er.code = "ENOTASHIM";
|
|
288
|
-
er.message = `Can't read shim path from '${path}', ` + `it doesn't appear to be a cmd-shim`;
|
|
289
|
-
return er;
|
|
290
|
-
};
|
|
291
|
-
var readCmdShim = (path) => {
|
|
292
|
-
const er = new Error;
|
|
293
|
-
Error.captureStackTrace(er, readCmdShim);
|
|
294
|
-
return readFile(path).then((contents) => {
|
|
295
|
-
const destination = extractPath(path, contents.toString());
|
|
296
|
-
if (destination) {
|
|
297
|
-
return destination;
|
|
298
|
-
}
|
|
299
|
-
throw notaShim(path, er);
|
|
300
|
-
}, (readFileEr) => {
|
|
301
|
-
throw wrapError(readFileEr, er);
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
var readCmdShimSync = (path) => {
|
|
305
|
-
const contents = readFileSync(path);
|
|
306
|
-
const destination = extractPath(path, contents.toString());
|
|
307
|
-
if (!destination) {
|
|
308
|
-
throw notaShim(path);
|
|
309
|
-
}
|
|
310
|
-
return destination;
|
|
311
|
-
};
|
|
312
|
-
readCmdShim.sync = readCmdShimSync;
|
|
313
|
-
module2.exports = readCmdShim;
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
// scripts/wq-switch/config.ts
|
|
317
|
-
var import_node_fs = require("node:fs");
|
|
318
|
-
var import_node_path2 = require("node:path");
|
|
319
|
-
|
|
320
|
-
// scripts/wq-switch/paths.ts
|
|
321
|
-
var import_node_path = require("node:path");
|
|
322
|
-
function projectPaths(root) {
|
|
323
|
-
const directory = import_node_path.join(root, ".webquark");
|
|
324
|
-
const stateDirectory = import_node_path.join(directory, "state");
|
|
325
|
-
return {
|
|
326
|
-
directory,
|
|
327
|
-
config: import_node_path.join(directory, ".webquark.json"),
|
|
328
|
-
packages: import_node_path.join(directory, "generated", "packages"),
|
|
329
|
-
state: import_node_path.join(stateDirectory, "state.json"),
|
|
330
|
-
journal: import_node_path.join(stateDirectory, "journal.json")
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// scripts/wq-switch/config.ts
|
|
335
|
-
var names = ["@webquark/core", "@webquark/browser", "@webquark/tooling", "@webquark/angular", "@webquark/react"];
|
|
336
|
-
var packageDirectories = {
|
|
337
|
-
"@webquark/core": "packages/core",
|
|
338
|
-
"@webquark/browser": "packages/browser/components",
|
|
339
|
-
"@webquark/tooling": "packages/tooling",
|
|
340
|
-
"@webquark/angular": "packages/browser/angular",
|
|
341
|
-
"@webquark/react": "packages/browser/react"
|
|
342
|
-
};
|
|
343
|
-
var localDependencies = {
|
|
344
|
-
"@webquark/core": ["@webquark/browser", "@webquark/tooling"],
|
|
345
|
-
"@webquark/browser": [],
|
|
346
|
-
"@webquark/tooling": [],
|
|
347
|
-
"@webquark/angular": ["@webquark/browser"],
|
|
348
|
-
"@webquark/react": ["@webquark/browser"]
|
|
349
|
-
};
|
|
350
|
-
function readWebQuarkConfig(root) {
|
|
351
|
-
const file = projectPaths(root).config;
|
|
352
|
-
if (!import_node_fs.existsSync(file))
|
|
353
|
-
return {};
|
|
354
|
-
const value = json(file);
|
|
355
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
356
|
-
throw new Error(`Invalid ${file}; expected a JSON object.`);
|
|
357
|
-
return value;
|
|
358
|
-
}
|
|
359
|
-
function readSwitchConfig(root) {
|
|
360
|
-
const document = readWebQuarkConfig(root);
|
|
361
|
-
const value = document["wq-switch"];
|
|
362
|
-
if (value === undefined)
|
|
363
|
-
return;
|
|
364
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || value.version !== 1 || typeof value.source !== "string" || value.preferredVersion !== undefined && typeof value.preferredVersion !== "string") {
|
|
365
|
-
throw new Error(`Invalid WebQuark wq-switch configuration; existing configuration was not overwritten.`);
|
|
366
|
-
}
|
|
367
|
-
return value;
|
|
368
|
-
}
|
|
369
|
-
function json(file) {
|
|
370
|
-
return JSON.parse(import_node_fs.readFileSync(file, "utf8"));
|
|
371
|
-
}
|
|
372
|
-
function manifest(root) {
|
|
373
|
-
return json(import_node_path2.join(root, "package.json"));
|
|
374
|
-
}
|
|
375
|
-
function writeJson(file, value) {
|
|
376
|
-
import_node_fs.mkdirSync(import_node_path2.dirname(file), { recursive: true });
|
|
377
|
-
const temporary = `${file}.${process.pid}.tmp`;
|
|
378
|
-
import_node_fs.writeFileSync(temporary, JSON.stringify(value, null, 2) + `
|
|
379
|
-
`);
|
|
380
|
-
import_node_fs.renameSync(temporary, file);
|
|
381
|
-
}
|
|
382
|
-
function consumerRoot(cwd = process.cwd()) {
|
|
383
|
-
let root = import_node_path2.resolve(cwd);
|
|
384
|
-
while (!import_node_fs.existsSync(import_node_path2.join(root, "package.json"))) {
|
|
385
|
-
const parent = import_node_path2.dirname(root);
|
|
386
|
-
if (parent === root)
|
|
387
|
-
throw new Error("Run this command inside the consuming project.");
|
|
388
|
-
root = parent;
|
|
389
|
-
}
|
|
390
|
-
const pkg = manifest(root);
|
|
391
|
-
if (names.includes(pkg.name) || pkg.private && pkg.scripts?.["packages:build"])
|
|
392
|
-
throw new Error("Run wq-switch in the consuming app, not the WebQuark repository.");
|
|
393
|
-
return import_node_fs.realpathSync(root);
|
|
394
|
-
}
|
|
395
|
-
function validateSource(source) {
|
|
396
|
-
const root = import_node_fs.realpathSync(import_node_path2.resolve(source));
|
|
397
|
-
const pkg = manifest(root);
|
|
398
|
-
if (!pkg.private || !pkg.scripts?.["packages:build"] || !names.every((name) => import_node_fs.existsSync(import_node_path2.join(root, packageDirectories[name], "package.json")) && manifest(import_node_path2.join(root, packageDirectories[name])).name === name)) {
|
|
399
|
-
throw new Error("Source must be the private WebQuark repository root, with packages:build and all five package manifests.");
|
|
400
|
-
}
|
|
401
|
-
return root;
|
|
402
|
-
}
|
|
403
|
-
function sourceFor(root) {
|
|
404
|
-
const config = readSwitchConfig(root);
|
|
405
|
-
if (!config)
|
|
406
|
-
throw new Error("First run: wq-setup");
|
|
407
|
-
if (!config.source.trim())
|
|
408
|
-
throw new Error('Set source inside "wq-switch" in .webquark/.webquark.json to your WebQuark repository, or run wq-setup --source "path/to/WebQuark".');
|
|
409
|
-
return validateSource(import_node_path2.resolve(root, config.source));
|
|
410
|
-
}
|
|
411
|
-
function selectedPackages(root) {
|
|
412
|
-
const pkg = manifest(root);
|
|
413
|
-
const dependencies = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
414
|
-
const selected = new Set(names.filter((name) => dependencies[name]));
|
|
415
|
-
if (!selected.size)
|
|
416
|
-
throw new Error("The consuming project must declare a WebQuark package.");
|
|
417
|
-
for (const name of selected)
|
|
418
|
-
for (const dependency of localDependencies[name])
|
|
419
|
-
selected.add(dependency);
|
|
420
|
-
return names.filter((name) => selected.has(name));
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// scripts/wq-switch/state.ts
|
|
424
|
-
var import_node_fs3 = require("node:fs");
|
|
425
|
-
var import_node_path4 = require("node:path");
|
|
426
|
-
var import_node_crypto2 = require("node:crypto");
|
|
427
|
-
var import_node_os = require("node:os");
|
|
428
|
-
|
|
429
|
-
// scripts/wq-switch/bins.ts
|
|
430
|
-
var import_node_fs2 = require("node:fs");
|
|
431
|
-
var import_node_crypto = require("node:crypto");
|
|
432
|
-
var import_node_path3 = require("node:path");
|
|
433
|
-
var import_cmd_shim = __toESM(require_lib());
|
|
434
|
-
var import_read_cmd_shim = __toESM(require_lib2());
|
|
435
|
-
var extensions = process.platform === "win32" ? ["", ".cmd", ".ps1", ".exe", ".bunx"] : [""];
|
|
436
|
-
function validName(name) {
|
|
437
|
-
return /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name) && !/^(con|prn|aux|nul|com\d|lpt\d)(\.|$)/i.test(name);
|
|
438
|
-
}
|
|
439
|
-
function snapshot(file) {
|
|
440
|
-
if (!present(file))
|
|
441
|
-
return null;
|
|
442
|
-
const stat = import_node_fs2.lstatSync(file);
|
|
443
|
-
if (stat.isSymbolicLink())
|
|
444
|
-
return { link: import_node_fs2.readlinkSync(file) };
|
|
445
|
-
if (!stat.isFile())
|
|
446
|
-
throw new Error(`Unexpected launcher entry: ${file}`);
|
|
447
|
-
return { data: import_node_fs2.readFileSync(file).toString("base64"), mode: stat.mode & 511 };
|
|
448
|
-
}
|
|
449
|
-
function same(a, b) {
|
|
450
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
451
|
-
}
|
|
452
|
-
function activeArtifact(entry) {
|
|
453
|
-
return entry.active === undefined ? entry.original : entry.active;
|
|
454
|
-
}
|
|
455
|
-
function validateBins(root, bins = []) {
|
|
456
|
-
const seen = new Set;
|
|
457
|
-
for (const entry of bins) {
|
|
458
|
-
const name = import_node_path3.relative(import_node_path3.join(root, "node_modules", ".bin"), entry.file);
|
|
459
|
-
if (!validName(name) || entry.file !== import_node_path3.join(root, "node_modules", ".bin", name) || seen.has(entry.file.toLowerCase()))
|
|
460
|
-
throw new Error("Invalid switch launcher path.");
|
|
461
|
-
seen.add(entry.file.toLowerCase());
|
|
462
|
-
for (const value of [entry.original, activeArtifact(entry)]) {
|
|
463
|
-
if (value !== null && (!value || typeof value !== "object" || ("link" in value ? typeof value.link !== "string" : typeof value.data !== "string" || !Number.isInteger(value.mode) || value.mode < 0 || value.mode > 511)))
|
|
464
|
-
throw new Error("Invalid switch launcher artifact.");
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
function assertBins(state) {
|
|
469
|
-
for (const entry of state.bins ?? []) {
|
|
470
|
-
if (!same(snapshot(entry.file), activeArtifact(entry)))
|
|
471
|
-
throw new Error(`Launcher changed by another install: ${entry.file}. Refusing to overwrite it.`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
function put(file, value) {
|
|
475
|
-
if (value === null) {
|
|
476
|
-
if (present(file))
|
|
477
|
-
import_node_fs2.unlinkSync(file);
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
import_node_fs2.mkdirSync(import_node_path3.dirname(file), { recursive: true });
|
|
481
|
-
const temporary = `${file}.wq-${import_node_crypto.randomUUID()}.tmp`;
|
|
482
|
-
try {
|
|
483
|
-
if ("link" in value)
|
|
484
|
-
import_node_fs2.symlinkSync(value.link, temporary, "file");
|
|
485
|
-
else {
|
|
486
|
-
import_node_fs2.writeFileSync(temporary, Buffer.from(value.data, "base64"), { flag: "wx" });
|
|
487
|
-
import_node_fs2.chmodSync(temporary, value.mode);
|
|
488
|
-
}
|
|
489
|
-
import_node_fs2.renameSync(temporary, file);
|
|
490
|
-
} finally {
|
|
491
|
-
if (present(temporary))
|
|
492
|
-
import_node_fs2.unlinkSync(temporary);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function changeBin(operation, rollback = false) {
|
|
496
|
-
const expected = rollback ? operation.after : operation.before;
|
|
497
|
-
const desired = rollback ? operation.before : operation.after;
|
|
498
|
-
const actual = snapshot(operation.file);
|
|
499
|
-
if (same(actual, desired))
|
|
500
|
-
return;
|
|
501
|
-
if (!same(actual, expected))
|
|
502
|
-
throw new Error(`Launcher changed during switching: ${operation.file}. Refusing to overwrite it.`);
|
|
503
|
-
put(operation.file, desired);
|
|
504
|
-
}
|
|
505
|
-
function binOperations(previous, next) {
|
|
506
|
-
const entries = next?.bins ?? previous?.bins ?? [];
|
|
507
|
-
return entries.map((entry) => ({ file: entry.file, before: previous?.bins?.find((old) => old.file === entry.file) ? activeArtifact(previous.bins.find((old) => old.file === entry.file)) : entry.original, after: next ? activeArtifact(entry) : entry.original }));
|
|
508
|
-
}
|
|
509
|
-
function targets(state, originals = false) {
|
|
510
|
-
const bins = new Map;
|
|
511
|
-
for (const entry of state.entries) {
|
|
512
|
-
const directory = originals ? entry.identity ? present(entry.backup) ? entry.backup : entry.slot : entry.original : entry.target;
|
|
513
|
-
if (!directory || !import_node_fs2.existsSync(import_node_path3.join(directory, "package.json")))
|
|
514
|
-
continue;
|
|
515
|
-
for (const [name, path] of Object.entries(manifest(directory).bin ?? {})) {
|
|
516
|
-
if (!validName(name))
|
|
517
|
-
throw new Error(`Invalid package binary name: ${name}`);
|
|
518
|
-
const target = import_node_path3.resolve(directory, path);
|
|
519
|
-
if (!within(directory, target) || !import_node_fs2.existsSync(target) || !import_node_fs2.statSync(target).isFile())
|
|
520
|
-
throw new Error(`Invalid package binary target: ${target}`);
|
|
521
|
-
if (!bins.has(name))
|
|
522
|
-
bins.set(name, target);
|
|
523
|
-
else if (name !== "wq-changelog" || entry.name !== "@webquark/tooling")
|
|
524
|
-
throw new Error(`Duplicate package binary: ${name}`);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return bins;
|
|
528
|
-
}
|
|
529
|
-
function owned(file, value, allowed) {
|
|
530
|
-
if ("link" in value)
|
|
531
|
-
return allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), value.link));
|
|
532
|
-
if (/\.(exe|bunx)$/i.test(file)) {
|
|
533
|
-
const companion = file.replace(/\.(exe|bunx)$/i, ".bunx");
|
|
534
|
-
if (!import_node_fs2.existsSync(companion))
|
|
535
|
-
return false;
|
|
536
|
-
const path = import_node_fs2.readFileSync(companion).toString("utf16le").match(/^([^"\0]+)"\0/)?.[1];
|
|
537
|
-
return !!path && allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), "..", path));
|
|
538
|
-
}
|
|
539
|
-
try {
|
|
540
|
-
return allowed.has(import_node_path3.resolve(import_node_path3.dirname(file), import_read_cmd_shim.default.sync(file)));
|
|
541
|
-
} catch {
|
|
542
|
-
return false;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
async function stageBins(root, next) {
|
|
546
|
-
const previous = readState(root);
|
|
547
|
-
if (previous)
|
|
548
|
-
assertBins(previous);
|
|
549
|
-
const desired = targets(next), original = targets(previous ?? next, true);
|
|
550
|
-
const old = new Map((previous?.bins ?? []).map((entry) => [entry.file, entry]));
|
|
551
|
-
const names = new Set([...desired.keys(), ...original.keys()]);
|
|
552
|
-
const staging = import_node_path3.join(next.generation, "node_modules", ".bin");
|
|
553
|
-
import_node_fs2.mkdirSync(staging, { recursive: true });
|
|
554
|
-
for (const [name, target] of desired) {
|
|
555
|
-
const file = import_node_path3.join(staging, name);
|
|
556
|
-
if (process.platform === "win32")
|
|
557
|
-
await import_cmd_shim.default(target, file);
|
|
558
|
-
else {
|
|
559
|
-
import_node_fs2.chmodSync(target, import_node_fs2.lstatSync(target).mode | 73);
|
|
560
|
-
if (present(file))
|
|
561
|
-
import_node_fs2.unlinkSync(file);
|
|
562
|
-
import_node_fs2.symlinkSync(import_node_path3.relative(staging, target), file, "file");
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
const bins = [];
|
|
566
|
-
for (const name of names) {
|
|
567
|
-
const allowed = new Set;
|
|
568
|
-
for (const entry of next.entries) {
|
|
569
|
-
for (const directory of [entry.slot, entry.target, entry.original, entry.backup]) {
|
|
570
|
-
if (!directory || !import_node_fs2.existsSync(import_node_path3.join(directory, "package.json")))
|
|
571
|
-
continue;
|
|
572
|
-
const path = manifest(directory).bin?.[name];
|
|
573
|
-
if (path) {
|
|
574
|
-
allowed.add(import_node_path3.resolve(directory, path));
|
|
575
|
-
allowed.add(import_node_path3.resolve(entry.slot, path));
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
const desiredTarget = desired.get(name);
|
|
580
|
-
const stableTarget = desiredTarget && import_node_path3.resolve(root, "node_modules", import_node_path3.relative(import_node_path3.join(next.generation, "node_modules"), desiredTarget));
|
|
581
|
-
const runtime = desiredTarget && import_node_fs2.readFileSync(desiredTarget, "utf8").match(/^#!\/usr\/bin\/env[ \t]+(node|bun)[ \t]*(?:\r?\n|$)/)?.[1];
|
|
582
|
-
const retainBun = process.platform === "win32" && stableTarget && [".exe", ".bunx"].every((extension) => {
|
|
583
|
-
const file = import_node_path3.join(root, "node_modules", ".bin", name + extension);
|
|
584
|
-
const value = snapshot(file);
|
|
585
|
-
return value !== null && owned(file, value, new Set([stableTarget]));
|
|
586
|
-
}) && runtime && import_node_fs2.readFileSync(import_node_path3.join(root, "node_modules", ".bin", name + ".bunx")).toString("utf16le").includes(`"\x00${runtime} `);
|
|
587
|
-
const running = process.argv[1] && import_node_fs2.existsSync(process.argv[1]) ? import_node_fs2.realpathSync(process.argv[1]) : "";
|
|
588
|
-
if (process.platform === "win32" && !retainBun && present(import_node_path3.join(root, "node_modules", ".bin", name + ".exe")) && [...allowed].some((target) => import_node_fs2.existsSync(target) && import_node_fs2.realpathSync(target) === running)) {
|
|
589
|
-
throw new Error(`The currently running Windows launcher would change: ${name}. Run the checkout's scripts/wq-switch/dist/index.js with node and retry.`);
|
|
590
|
-
}
|
|
591
|
-
for (const extension of extensions) {
|
|
592
|
-
const file = import_node_path3.join(root, "node_modules", ".bin", name + extension), current = snapshot(file);
|
|
593
|
-
const saved = old.get(file);
|
|
594
|
-
if (!saved && current && !owned(file, current, allowed))
|
|
595
|
-
throw new Error(`Foreign launcher collision: ${file}. Refusing to overwrite it.`);
|
|
596
|
-
const active = retainBun && [".exe", ".bunx"].includes(extension) ? current : snapshot(import_node_path3.join(staging, name + extension));
|
|
597
|
-
const baseline = saved ? saved.original : current;
|
|
598
|
-
bins.push({ file, original: baseline, ...!same(active, baseline) ? { active } : {} });
|
|
599
|
-
old.delete(file);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
for (const saved of old.values())
|
|
603
|
-
bins.push({ ...saved, active: null });
|
|
604
|
-
next.bins = bins;
|
|
605
|
-
validateBins(root, bins);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// scripts/wq-switch/state.ts
|
|
609
|
-
function identity(file) {
|
|
610
|
-
const stat = import_node_fs3.statSync(file);
|
|
611
|
-
return `${stat.dev}:${stat.ino}`;
|
|
612
|
-
}
|
|
613
|
-
function present(file) {
|
|
614
|
-
try {
|
|
615
|
-
import_node_fs3.lstatSync(file);
|
|
616
|
-
return true;
|
|
617
|
-
} catch (error) {
|
|
618
|
-
if (error.code === "ENOENT")
|
|
619
|
-
return false;
|
|
620
|
-
throw error;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
function within(parent, child) {
|
|
624
|
-
const r = import_node_path4.relative(parent, child);
|
|
625
|
-
return r !== "" && !r.startsWith("..") && !import_node_path4.isAbsolute(r);
|
|
626
|
-
}
|
|
627
|
-
function linkTarget(file) {
|
|
628
|
-
if (!present(file) || !import_node_fs3.lstatSync(file).isSymbolicLink())
|
|
629
|
-
return null;
|
|
630
|
-
return import_node_path4.resolve(import_node_path4.dirname(file), import_node_fs3.readlinkSync(file));
|
|
631
|
-
}
|
|
632
|
-
function link(target, file) {
|
|
633
|
-
import_node_fs3.mkdirSync(import_node_path4.dirname(file), { recursive: true });
|
|
634
|
-
import_node_fs3.symlinkSync(target, file, process.platform === "win32" ? "junction" : "dir");
|
|
635
|
-
}
|
|
636
|
-
function validateState(root, state, paths) {
|
|
637
|
-
if (state.version !== 1 || !Array.isArray(state.entries))
|
|
638
|
-
throw new Error("Unsupported switch state.");
|
|
639
|
-
if (!within(paths.packages, state.generation))
|
|
640
|
-
throw new Error("Invalid switch generation path; refusing filesystem changes.");
|
|
641
|
-
for (const entry of state.entries) {
|
|
642
|
-
if (!names.includes(entry.name) || entry.slot !== import_node_path4.join(root, "node_modules", entry.name) || import_node_path4.dirname(entry.backup) !== import_node_path4.dirname(entry.slot) || !entry.backup.startsWith(entry.slot + ".wq-original-") || !within(state.generation, entry.target))
|
|
643
|
-
throw new Error("Invalid switch state paths; refusing filesystem changes.");
|
|
644
|
-
}
|
|
645
|
-
validateBins(root, state.bins);
|
|
646
|
-
}
|
|
647
|
-
function readState(root) {
|
|
648
|
-
const paths = projectPaths(root);
|
|
649
|
-
if (!import_node_fs3.existsSync(paths.state))
|
|
650
|
-
return null;
|
|
651
|
-
const state = json(paths.state);
|
|
652
|
-
validateState(root, state, paths);
|
|
653
|
-
return state;
|
|
654
|
-
}
|
|
655
|
-
function saveState(state, paths) {
|
|
656
|
-
if (state)
|
|
657
|
-
writeJson(paths.state, state);
|
|
658
|
-
else if (import_node_fs3.existsSync(paths.state))
|
|
659
|
-
import_node_fs3.unlinkSync(paths.state);
|
|
660
|
-
}
|
|
661
|
-
function assertActive(state) {
|
|
662
|
-
for (const entry of state.entries) {
|
|
663
|
-
if (linkTarget(entry.slot) !== entry.target)
|
|
664
|
-
throw new Error(`${entry.name} was changed by another install. Refusing to overwrite it.`);
|
|
665
|
-
if (entry.identity && (!present(entry.backup) || identity(entry.backup) !== entry.identity))
|
|
666
|
-
throw new Error(`Original package backup is missing or changed: ${entry.backup}`);
|
|
667
|
-
}
|
|
668
|
-
assertBins(state);
|
|
669
|
-
}
|
|
670
|
-
function hasJournal(root) {
|
|
671
|
-
return import_node_fs3.existsSync(projectPaths(root).journal);
|
|
672
|
-
}
|
|
673
|
-
function removeExpectedLink(slot, expected) {
|
|
674
|
-
if (linkTarget(slot) !== expected)
|
|
675
|
-
throw new Error(`Package connection changed: ${slot}`);
|
|
676
|
-
import_node_fs3.unlinkSync(slot);
|
|
677
|
-
}
|
|
678
|
-
function validateJournal(root, journal, paths) {
|
|
679
|
-
if (journal.previous)
|
|
680
|
-
validateState(root, journal.previous, paths);
|
|
681
|
-
if (journal.next)
|
|
682
|
-
validateState(root, journal.next, paths);
|
|
683
|
-
const entries = [...journal.previous?.entries ?? [], ...journal.next?.entries ?? []];
|
|
684
|
-
for (const op of journal.operations) {
|
|
685
|
-
const matching = entries.filter((entry) => entry.slot === op.slot);
|
|
686
|
-
if (!matching.length || op.move && !matching.some((entry) => entry.backup === op.move) || [op.before, op.after].some((target) => target !== null && !matching.some((entry) => entry.target === target)))
|
|
687
|
-
throw new Error("Invalid recovery journal.");
|
|
688
|
-
}
|
|
689
|
-
if (JSON.stringify(journal.bins ?? []) !== JSON.stringify(binOperations(journal.previous, journal.next)))
|
|
690
|
-
throw new Error("Invalid launcher recovery journal.");
|
|
691
|
-
}
|
|
692
|
-
function recover(root) {
|
|
693
|
-
const paths = projectPaths(root);
|
|
694
|
-
if (!import_node_fs3.existsSync(paths.journal))
|
|
695
|
-
return;
|
|
696
|
-
const journal = json(paths.journal);
|
|
697
|
-
validateJournal(root, journal, paths);
|
|
698
|
-
for (const operation of [...journal.bins ?? []].reverse())
|
|
699
|
-
changeBin(operation, true);
|
|
700
|
-
for (const op of [...journal.operations].reverse()) {
|
|
701
|
-
if (op.move) {
|
|
702
|
-
const entry = journal.next.entries.find((entry) => entry.slot === op.slot);
|
|
703
|
-
if (!entry.identity) {
|
|
704
|
-
if (present(op.slot))
|
|
705
|
-
removeExpectedLink(op.slot, op.after);
|
|
706
|
-
continue;
|
|
707
|
-
}
|
|
708
|
-
if (present(op.move)) {
|
|
709
|
-
if (present(op.slot))
|
|
710
|
-
removeExpectedLink(op.slot, op.after);
|
|
711
|
-
import_node_fs3.renameSync(op.move, op.slot);
|
|
712
|
-
} else if (!present(op.slot) || identity(op.slot) !== entry.identity)
|
|
713
|
-
throw new Error(`Recovery needs the original package: ${op.slot}`);
|
|
714
|
-
} else if (op.after === null) {
|
|
715
|
-
const entry = journal.previous.entries.find((entry) => entry.slot === op.slot);
|
|
716
|
-
if (entry.identity && !present(entry.backup)) {
|
|
717
|
-
if (!present(op.slot) || identity(op.slot) !== entry.identity)
|
|
718
|
-
throw new Error(`Recovery found an unexpected package: ${op.slot}`);
|
|
719
|
-
import_node_fs3.renameSync(op.slot, entry.backup);
|
|
720
|
-
}
|
|
721
|
-
if (!present(op.slot))
|
|
722
|
-
link(op.before, op.slot);
|
|
723
|
-
else if (linkTarget(op.slot) !== op.before)
|
|
724
|
-
throw new Error(`Recovery found an unexpected connection: ${op.slot}`);
|
|
725
|
-
} else {
|
|
726
|
-
const current = linkTarget(op.slot);
|
|
727
|
-
if (current === op.after)
|
|
728
|
-
removeExpectedLink(op.slot, op.after);
|
|
729
|
-
else if (present(op.slot) && current !== op.before)
|
|
730
|
-
throw new Error(`Recovery found an unexpected connection: ${op.slot}`);
|
|
731
|
-
if (!present(op.slot))
|
|
732
|
-
link(op.before, op.slot);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
saveState(journal.previous, paths);
|
|
736
|
-
import_node_fs3.unlinkSync(paths.journal);
|
|
737
|
-
}
|
|
738
|
-
function activate(root, next) {
|
|
739
|
-
const paths = projectPaths(root);
|
|
740
|
-
validateState(root, next, paths);
|
|
741
|
-
const previous = readState(root);
|
|
742
|
-
if (previous)
|
|
743
|
-
assertActive(previous);
|
|
744
|
-
const operations = next.entries.map((entry) => {
|
|
745
|
-
const old = previous?.entries.find((old) => old.name === entry.name);
|
|
746
|
-
if (!old && (present(entry.backup) || (entry.identity ? !present(entry.slot) || identity(entry.slot) !== entry.identity : present(entry.slot))))
|
|
747
|
-
throw new Error(`Original connection changed: ${entry.name}`);
|
|
748
|
-
return { slot: entry.slot, before: old?.target ?? null, after: entry.target, ...old ? {} : { move: entry.backup } };
|
|
749
|
-
});
|
|
750
|
-
const bins = binOperations(previous, next);
|
|
751
|
-
writeJson(paths.journal, { previous, next, operations, bins });
|
|
752
|
-
try {
|
|
753
|
-
for (const op of operations) {
|
|
754
|
-
if (op.move) {
|
|
755
|
-
if (present(op.slot))
|
|
756
|
-
import_node_fs3.renameSync(op.slot, op.move);
|
|
757
|
-
} else
|
|
758
|
-
removeExpectedLink(op.slot, op.before);
|
|
759
|
-
link(op.after, op.slot);
|
|
760
|
-
}
|
|
761
|
-
for (const operation of bins)
|
|
762
|
-
changeBin(operation);
|
|
763
|
-
saveState(next, paths);
|
|
764
|
-
import_node_fs3.unlinkSync(paths.journal);
|
|
765
|
-
} catch (error) {
|
|
766
|
-
recover(root);
|
|
767
|
-
throw error;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
function restore(root) {
|
|
771
|
-
const paths = projectPaths(root);
|
|
772
|
-
const previous = readState(root);
|
|
773
|
-
if (!previous)
|
|
774
|
-
return;
|
|
775
|
-
assertActive(previous);
|
|
776
|
-
const operations = previous.entries.map((entry) => ({ slot: entry.slot, before: entry.target, after: null }));
|
|
777
|
-
const bins = binOperations(previous, null);
|
|
778
|
-
writeJson(paths.journal, { previous, next: null, operations, bins });
|
|
779
|
-
try {
|
|
780
|
-
for (const entry of previous.entries) {
|
|
781
|
-
removeExpectedLink(entry.slot, entry.target);
|
|
782
|
-
if (entry.identity)
|
|
783
|
-
import_node_fs3.renameSync(entry.backup, entry.slot);
|
|
784
|
-
}
|
|
785
|
-
for (const operation of bins)
|
|
786
|
-
changeBin(operation);
|
|
787
|
-
saveState(null, paths);
|
|
788
|
-
import_node_fs3.unlinkSync(paths.journal);
|
|
789
|
-
} catch (error) {
|
|
790
|
-
recover(root);
|
|
791
|
-
throw error;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
function originalEntry(root, name, target) {
|
|
795
|
-
const slot = import_node_path4.join(root, "node_modules", name);
|
|
796
|
-
return { name, slot, backup: `${slot}.wq-original-${import_node_crypto2.randomUUID()}`, original: present(slot) ? import_node_fs3.realpathSync(slot) : "", identity: present(slot) ? identity(slot) : "", target };
|
|
797
|
-
}
|
|
798
|
-
async function locked(key, action) {
|
|
799
|
-
const file = import_node_path4.join(import_node_os.tmpdir(), `wq-switch-${import_node_crypto2.createHash("sha256").update(key.toLowerCase()).digest("hex")}.lock`);
|
|
800
|
-
const content = JSON.stringify({ pid: process.pid, id: import_node_crypto2.randomUUID() });
|
|
801
|
-
try {
|
|
802
|
-
import_node_fs3.writeFileSync(file, content, { flag: "wx" });
|
|
803
|
-
} catch (error) {
|
|
804
|
-
if (error.code !== "EEXIST")
|
|
805
|
-
throw error;
|
|
806
|
-
const previous = import_node_fs3.readFileSync(file, "utf8");
|
|
807
|
-
const { pid } = JSON.parse(previous);
|
|
808
|
-
let alive = true;
|
|
809
|
-
try {
|
|
810
|
-
process.kill(pid, 0);
|
|
811
|
-
} catch (e) {
|
|
812
|
-
if (e.code === "ESRCH")
|
|
813
|
-
alive = false;
|
|
814
|
-
}
|
|
815
|
-
if (alive)
|
|
816
|
-
throw new Error(`Another switch/build is running (PID ${pid}).`);
|
|
817
|
-
if (import_node_fs3.readFileSync(file, "utf8") !== previous)
|
|
818
|
-
throw new Error("Lock changed; retry.");
|
|
819
|
-
import_node_fs3.unlinkSync(file);
|
|
820
|
-
import_node_fs3.writeFileSync(file, content, { flag: "wx" });
|
|
821
|
-
}
|
|
822
|
-
try {
|
|
823
|
-
return await action();
|
|
824
|
-
} finally {
|
|
825
|
-
if (import_node_fs3.existsSync(file) && import_node_fs3.readFileSync(file, "utf8") === content)
|
|
826
|
-
import_node_fs3.unlinkSync(file);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
// scripts/wq-switch/commands/setup.ts
|
|
831
|
-
var import_node_fs4 = require("node:fs");
|
|
832
|
-
var import_node_path5 = require("node:path");
|
|
833
|
-
function setup(root, source) {
|
|
834
|
-
const selected = selectedPackages(root);
|
|
835
|
-
if (hasJournal(root))
|
|
836
|
-
throw new Error("Run wq-switch npm to recover the interrupted switch before changing configuration.");
|
|
837
|
-
if (readState(root))
|
|
838
|
-
throw new Error("Stop the dev server and run wq-switch npm before changing configuration.");
|
|
839
|
-
const file = projectPaths(root).config;
|
|
840
|
-
const document = readWebQuarkConfig(root);
|
|
841
|
-
const previous = readSwitchConfig(root);
|
|
842
|
-
const pkg = manifest(root);
|
|
843
|
-
const scripts = { "wq-sandbox": "wq-sandbox", "wq-switch": "wq-switch", "wq-check": "wq-switch check" };
|
|
844
|
-
for (const [name, command] of Object.entries(scripts)) {
|
|
845
|
-
if (pkg.scripts?.[name] && pkg.scripts[name] !== command)
|
|
846
|
-
throw new Error(`package.json already has a custom ${name} script. Rename it before running setup; no files were changed.`);
|
|
847
|
-
}
|
|
848
|
-
const config = {
|
|
849
|
-
...previous,
|
|
850
|
-
version: 1,
|
|
851
|
-
source: source === undefined ? previous?.source ?? "" : validateSource(import_node_path5.resolve(root, source)),
|
|
852
|
-
preferredVersion: previous?.preferredVersion ?? selected.map((name) => pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]).find(Boolean)
|
|
853
|
-
};
|
|
854
|
-
writeJson(file, { ...document, "wq-switch": config });
|
|
855
|
-
writeJson(import_node_path5.join(root, "package.json"), { ...pkg, scripts: { ...pkg.scripts, ...scripts } });
|
|
856
|
-
const ignore = import_node_path5.join(root, ".gitignore");
|
|
857
|
-
const current = import_node_fs4.existsSync(ignore) ? import_node_fs4.readFileSync(ignore, "utf8") : "";
|
|
858
|
-
const missing = ["/.webquark/", "/node_modules/"].filter((line) => !current.split(/\r?\n/).includes(line));
|
|
859
|
-
if (missing.length)
|
|
860
|
-
import_node_fs4.appendFileSync(ignore, `
|
|
861
|
-
# Local WebQuark development
|
|
862
|
-
` + missing.join(`
|
|
863
|
-
`) + `
|
|
864
|
-
`);
|
|
865
|
-
console.log(`Created/updated .webquark/.webquark.json and package scripts.
|
|
866
|
-
Preferred release: ${config.preferredVersion}
|
|
867
|
-
${config.source ? `Source: ${config.source}
|
|
868
|
-
Next: bun run wq-switch local` : "Next: fill in wq-switch.source in .webquark/.webquark.json before switching locally."}
|
|
869
|
-
Sandbox: bun run wq-sandbox
|
|
870
|
-
Status: bun run wq-switch status`);
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// scripts/wq-switch/commands/build.ts
|
|
874
|
-
var import_node_child_process = require("node:child_process");
|
|
875
|
-
|
|
876
|
-
// scripts/wq-switch/packages.ts
|
|
877
|
-
var import_node_fs5 = require("node:fs");
|
|
878
|
-
var import_node_module = require("node:module");
|
|
879
|
-
var import_node_path6 = require("node:path");
|
|
880
|
-
var import_node_crypto3 = require("node:crypto");
|
|
881
|
-
function installed(name, from) {
|
|
882
|
-
const require2 = import_node_module.createRequire(import_node_path6.join(from, "package.json"));
|
|
883
|
-
for (const directory of require2.resolve.paths(name) ?? []) {
|
|
884
|
-
const candidate = import_node_path6.join(directory, name);
|
|
885
|
-
if (import_node_fs5.existsSync(import_node_path6.join(candidate, "package.json")) && manifest(candidate).name === name)
|
|
886
|
-
return import_node_fs5.realpathSync(candidate);
|
|
887
|
-
}
|
|
888
|
-
throw new Error(`Cannot resolve ${name} from ${from}. Install the consumer dependencies first.`);
|
|
889
|
-
}
|
|
890
|
-
function installedWebQuark(name, root) {
|
|
891
|
-
try {
|
|
892
|
-
return installed(name, root);
|
|
893
|
-
} catch (error) {
|
|
894
|
-
for (const owner of names.filter((candidate) => localDependencies[candidate].includes(name))) {
|
|
895
|
-
try {
|
|
896
|
-
return installed(name, installed(owner, root));
|
|
897
|
-
} catch {}
|
|
898
|
-
}
|
|
899
|
-
throw error;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
function validatePackage(directory) {
|
|
903
|
-
const pkg = manifest(directory);
|
|
904
|
-
const entries = [pkg.main, pkg.module, pkg.types, ...Object.values(pkg.bin ?? {})].filter((value) => !!value);
|
|
905
|
-
function visit(value) {
|
|
906
|
-
if (typeof value === "string" && value.startsWith("./") && !value.includes("*"))
|
|
907
|
-
entries.push(value);
|
|
908
|
-
else if (value && typeof value === "object")
|
|
909
|
-
Object.values(value).forEach(visit);
|
|
910
|
-
}
|
|
911
|
-
visit(pkg.exports);
|
|
912
|
-
for (const entry of entries) {
|
|
913
|
-
const file = import_node_path6.resolve(directory, entry);
|
|
914
|
-
if (!within(directory, file) || !import_node_fs5.existsSync(file) || !import_node_fs5.statSync(file).isFile())
|
|
915
|
-
throw new Error(`Missing or invalid build output: ${file}`);
|
|
916
|
-
}
|
|
917
|
-
if (pkg.name === "@webquark/core" && !pkg.bin?.["wq-switch"])
|
|
918
|
-
throw new Error("Local WebQuark must include the wq-switch CLI. Update the checkout first.");
|
|
919
|
-
}
|
|
920
|
-
function stage(root, source) {
|
|
921
|
-
const selected = selectedPackages(root);
|
|
922
|
-
const previous = readState(root);
|
|
923
|
-
if (previous) {
|
|
924
|
-
assertActive(previous);
|
|
925
|
-
if (previous.source !== source || previous.entries.map((e) => e.name).join() !== selected.join())
|
|
926
|
-
throw new Error("Source or selected dependencies changed. Run wq-switch npm before switching again.");
|
|
927
|
-
}
|
|
928
|
-
const generation = import_node_path6.join(projectPaths(root).packages, import_node_crypto3.randomUUID());
|
|
929
|
-
const targets = new Map;
|
|
930
|
-
for (const name of selected) {
|
|
931
|
-
const directory = import_node_path6.join(source, packageDirectories[name]);
|
|
932
|
-
const pkg = manifest(directory);
|
|
933
|
-
if (pkg.name !== name || pkg.private)
|
|
934
|
-
throw new Error(`Invalid local package identity: ${directory}`);
|
|
935
|
-
for (const dependency of localDependencies[name]) {
|
|
936
|
-
if (pkg.dependencies?.[dependency] !== pkg.version || manifest(import_node_path6.join(source, packageDirectories[dependency])).version !== pkg.version) {
|
|
937
|
-
throw new Error(`${name} must depend on the same local version of ${dependency}.`);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
validatePackage(directory);
|
|
941
|
-
const target = import_node_path6.join(generation, "node_modules", name);
|
|
942
|
-
import_node_fs5.mkdirSync(target, { recursive: true });
|
|
943
|
-
import_node_fs5.cpSync(import_node_path6.join(directory, "package.json"), import_node_path6.join(target, "package.json"));
|
|
944
|
-
for (const file of manifest(directory).files ?? []) {
|
|
945
|
-
if (/[*?]/.test(file))
|
|
946
|
-
throw new Error(`Unsupported package files glob: ${file}`);
|
|
947
|
-
const from = import_node_path6.resolve(directory, file), to = import_node_path6.resolve(target, file);
|
|
948
|
-
if (!within(directory, from) || !within(target, to))
|
|
949
|
-
throw new Error("Package file escapes package root.");
|
|
950
|
-
if (import_node_fs5.existsSync(from))
|
|
951
|
-
import_node_fs5.cpSync(from, to, { recursive: true, dereference: true });
|
|
952
|
-
}
|
|
953
|
-
validatePackage(target);
|
|
954
|
-
targets.set(name, target);
|
|
955
|
-
}
|
|
956
|
-
const originals = new Map;
|
|
957
|
-
for (const name of selected) {
|
|
958
|
-
const saved = previous?.entries.find((e) => e.name === name);
|
|
959
|
-
if (saved) {
|
|
960
|
-
originals.set(name, saved.identity ? import_node_fs5.realpathSync(saved.backup) : saved.original);
|
|
961
|
-
continue;
|
|
962
|
-
}
|
|
963
|
-
try {
|
|
964
|
-
originals.set(name, installed(name, root));
|
|
965
|
-
} catch {}
|
|
966
|
-
}
|
|
967
|
-
for (const name of selected) {
|
|
968
|
-
if (originals.has(name))
|
|
969
|
-
continue;
|
|
970
|
-
for (const from of originals.values()) {
|
|
971
|
-
if (!from)
|
|
972
|
-
continue;
|
|
973
|
-
try {
|
|
974
|
-
originals.set(name, installed(name, from));
|
|
975
|
-
break;
|
|
976
|
-
} catch {}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
const entries = selected.map((name) => {
|
|
980
|
-
const old = previous?.entries.find((entry) => entry.name === name);
|
|
981
|
-
if (old)
|
|
982
|
-
return { ...old, target: targets.get(name) };
|
|
983
|
-
const entry = originalEntry(root, name, targets.get(name));
|
|
984
|
-
if (!entry.original)
|
|
985
|
-
entry.original = originals.get(name) ?? "";
|
|
986
|
-
return entry;
|
|
987
|
-
});
|
|
988
|
-
for (const name of selected) {
|
|
989
|
-
const target = targets.get(name);
|
|
990
|
-
const pkg = manifest(target);
|
|
991
|
-
const original = originals.get(name) || names.filter((owner) => localDependencies[owner].includes(name)).map((owner) => originals.get(owner)).find((owner) => !!owner) || root;
|
|
992
|
-
const peers = pkg.peerDependencies ?? {};
|
|
993
|
-
const dependencies = { ...pkg.dependencies, ...peers };
|
|
994
|
-
for (const dependency of Object.keys(dependencies)) {
|
|
995
|
-
let resolved = targets.get(dependency);
|
|
996
|
-
if (!resolved) {
|
|
997
|
-
if (names.includes(dependency))
|
|
998
|
-
throw new Error(`Unexpected local WebQuark dependency: ${name} -> ${dependency}.`);
|
|
999
|
-
try {
|
|
1000
|
-
resolved = installed(dependency, dependency in peers ? root : original);
|
|
1001
|
-
} catch (error) {
|
|
1002
|
-
if (pkg.peerDependenciesMeta?.[dependency]?.optional)
|
|
1003
|
-
continue;
|
|
1004
|
-
throw error;
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
const owner = entries.find((entry) => entry.identity && within(entry.slot, resolved));
|
|
1008
|
-
if (owner)
|
|
1009
|
-
resolved = import_node_path6.join(owner.backup, import_node_path6.relative(owner.slot, resolved));
|
|
1010
|
-
link(resolved, import_node_path6.join(target, "node_modules", dependency));
|
|
1011
|
-
}
|
|
1012
|
-
for (const peer of ["react", "react-dom", "@angular/core", "@angular/common", "@angular/forms", "rxjs"]) {
|
|
1013
|
-
if (peer in peers && installed(peer, target) !== installed(peer, root))
|
|
1014
|
-
throw new Error(`Duplicate framework resolution: ${peer}`);
|
|
1015
|
-
}
|
|
1016
|
-
for (const dependency of localDependencies[name]) {
|
|
1017
|
-
if (installed(dependency, target) !== targets.get(dependency))
|
|
1018
|
-
throw new Error(`${name} resolves a different local ${dependency}.`);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
for (const entry of entries) {
|
|
1022
|
-
if (previous?.entries.some((saved) => saved.name === entry.name) || entry.identity || !entry.original)
|
|
1023
|
-
continue;
|
|
1024
|
-
const owner = entries.find((candidate) => candidate.identity && within(candidate.slot, entry.original));
|
|
1025
|
-
if (owner)
|
|
1026
|
-
entry.original = import_node_path6.join(owner.backup, import_node_path6.relative(owner.slot, entry.original));
|
|
1027
|
-
}
|
|
1028
|
-
return { version: 1, source, generation, entries };
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
// scripts/wq-switch/commands/build.ts
|
|
1032
|
-
async function compile(source) {
|
|
1033
|
-
console.log(`Building core, browser, tooling, React, and Angular in ${source}`);
|
|
1034
|
-
await new Promise((resolve, reject) => {
|
|
1035
|
-
const child = import_node_child_process.spawn("bun", ["run", "packages:build"], { cwd: source, stdio: "inherit", shell: false });
|
|
1036
|
-
child.on("error", reject);
|
|
1037
|
-
child.on("exit", (code, signal) => code === 0 ? resolve() : reject(new Error(`WebQuark build failed (${signal ?? code}). Active packages were not changed.`)));
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
async function build(root, connect = false) {
|
|
1041
|
-
const source = sourceFor(root);
|
|
1042
|
-
const active = readState(root);
|
|
1043
|
-
if (active) {
|
|
1044
|
-
assertActive(active);
|
|
1045
|
-
if (active.source !== source || active.entries.map((e) => e.name).join() !== selectedPackages(root).join())
|
|
1046
|
-
throw new Error("Configuration changed. Run wq-switch npm before switching again.");
|
|
1047
|
-
}
|
|
1048
|
-
await locked(`source:${source}`, async () => {
|
|
1049
|
-
await compile(source);
|
|
1050
|
-
if (connect || readState(root)) {
|
|
1051
|
-
const next = stage(root, source);
|
|
1052
|
-
await stageBins(root, next);
|
|
1053
|
-
activate(root, next);
|
|
1054
|
-
console.log(`LOCAL: ${source}
|
|
1055
|
-
Build activated. Restart the consumer dev server.`);
|
|
1056
|
-
} else
|
|
1057
|
-
console.log("Build complete. Package connections unchanged. Use wq-switch local to activate.");
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
// scripts/wq-switch/commands/local.ts
|
|
1062
|
-
async function local(root) {
|
|
1063
|
-
await build(root, true);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
// scripts/wq-switch/commands/npm.ts
|
|
1067
|
-
function npm(root) {
|
|
1068
|
-
restore(root);
|
|
1069
|
-
console.log(`NPM: original package connections restored. No versions or lockfiles changed.
|
|
1070
|
-
Restart the consumer dev server.`);
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// scripts/wq-switch/commands/status.ts
|
|
1074
|
-
var import_node_path7 = require("node:path");
|
|
1075
|
-
function status(root) {
|
|
1076
|
-
const state = readState(root);
|
|
1077
|
-
let broken = false, local = 0;
|
|
1078
|
-
const rows = [];
|
|
1079
|
-
for (const name of selectedPackages(root)) {
|
|
1080
|
-
try {
|
|
1081
|
-
const path = installedWebQuark(name, root);
|
|
1082
|
-
const entry = state?.entries.find((entry) => entry.name === name);
|
|
1083
|
-
if (entry && linkTarget(entry.slot) === entry.target) {
|
|
1084
|
-
validatePackage(path);
|
|
1085
|
-
local++;
|
|
1086
|
-
}
|
|
1087
|
-
const version = json(import_node_path7.join(path, "package.json")).version ?? "unknown";
|
|
1088
|
-
rows.push(`${name}@${version} -> ${path}`);
|
|
1089
|
-
} catch {
|
|
1090
|
-
broken = true;
|
|
1091
|
-
rows.push(`${name} -> MISSING`);
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
if (state) {
|
|
1095
|
-
try {
|
|
1096
|
-
assertBins(state);
|
|
1097
|
-
} catch (error) {
|
|
1098
|
-
broken = true;
|
|
1099
|
-
rows.push(error.message);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
const pending = hasJournal(root);
|
|
1103
|
-
const mode = pending ? "RECOVERY NEEDED" : broken ? "BROKEN" : state ? local === state.entries.length ? "LOCAL" : "MIXED" : "NPM / UNMANAGED";
|
|
1104
|
-
const config = readSwitchConfig(root);
|
|
1105
|
-
console.log(`Mode: ${mode}
|
|
1106
|
-
Source: ${config?.source || "not configured"}
|
|
1107
|
-
Preferred release: ${config?.preferredVersion ?? "not configured"}
|
|
1108
|
-
${rows.join(`
|
|
1109
|
-
`)}`);
|
|
1110
|
-
if (pending)
|
|
1111
|
-
console.log("Run wq-switch npm or local to recover the interrupted operation first.");
|
|
1112
|
-
if (state)
|
|
1113
|
-
console.log("Local files are snapshots of the last successful activation, not a live source link. The preferred release is not the active snapshot version. Run wq-switch build after source edits, then restart the consumer dev server.");
|
|
1114
|
-
if (broken || pending || state && local !== state.entries.length)
|
|
1115
|
-
process.exitCode = 1;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
// scripts/wq-switch/commands/check.ts
|
|
1119
|
-
var import_node_module2 = require("node:module");
|
|
1120
|
-
var import_node_fs6 = require("node:fs");
|
|
1121
|
-
var import_node_path8 = require("node:path");
|
|
1122
|
-
function check(root) {
|
|
1123
|
-
const selected = selectedPackages(root);
|
|
1124
|
-
if (!selected.includes("@webquark/browser")) {
|
|
1125
|
-
validatePackage(installed("@webquark/tooling", root));
|
|
1126
|
-
console.log("WebQuark tooling package entries are available.");
|
|
1127
|
-
if (readState(root) || hasJournal(root))
|
|
1128
|
-
status(root);
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
const pkg = manifest(root);
|
|
1132
|
-
const directBrowser = pkg.dependencies?.["@webquark/browser"] ?? pkg.devDependencies?.["@webquark/browser"];
|
|
1133
|
-
const stylesheet = !directBrowser && selected.includes("@webquark/core") ? "@webquark/core/browser/native-content.css" : "@webquark/browser/native-content.css";
|
|
1134
|
-
try {
|
|
1135
|
-
const wrapper = selected.find((name) => name === "@webquark/angular" || name === "@webquark/react");
|
|
1136
|
-
const from = !directBrowser && !selected.includes("@webquark/core") && wrapper ? installed(wrapper, root) : root;
|
|
1137
|
-
const file = import_node_module2.createRequire(import_node_path8.join(from, "package.json")).resolve(stylesheet);
|
|
1138
|
-
if (!import_node_fs6.statSync(file).isFile())
|
|
1139
|
-
throw new Error("The stylesheet is not a file.");
|
|
1140
|
-
} catch (error) {
|
|
1141
|
-
throw new Error('Could not resolve "' + stylesheet + `". The installed browser package or core browser forwarding entry must export this stylesheet and include its built CSS file.
|
|
1142
|
-
` + `For local development, run bun run wq-setup --source "<path-to-WebQuark>", then bun run wq-switch local.
|
|
1143
|
-
` + "wq-setup configures the checkout; wq-switch local builds and activates it. Alternatively, install matching published WebQuark packages containing this export.", { cause: error });
|
|
1144
|
-
}
|
|
1145
|
-
console.log("WebQuark native-content.css export and file are available.");
|
|
1146
|
-
if (readState(root) || hasJournal(root))
|
|
1147
|
-
status(root);
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// scripts/wq-switch/index.ts
|
|
1151
|
-
var help = `wq-switch — run inside the consuming project
|
|
1152
|
-
|
|
1153
|
-
setup [--source <path>] Create configuration and package scripts (also: wq-setup)
|
|
1154
|
-
local Build all packages and activate local snapshots
|
|
1155
|
-
build Build all packages; refresh snapshots if already local
|
|
1156
|
-
npm Restore original installed packages (no upgrade)
|
|
1157
|
-
check Verify the native-content.css export before bundling
|
|
1158
|
-
status Inspect actual package connections
|
|
1159
|
-
`;
|
|
1160
|
-
async function main() {
|
|
1161
|
-
const [command, ...args] = process.argv.slice(2);
|
|
1162
|
-
if (!command || command === "--help" || command === "-h") {
|
|
1163
|
-
console.log(help);
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
if (!["setup", "local", "build", "npm", "status", "check"].includes(command))
|
|
1167
|
-
throw new Error(`Unknown command: ${command}
|
|
1168
|
-
${help}`);
|
|
1169
|
-
if (command === "setup" ? args.length !== 0 && (args.length !== 2 || args[0] !== "--source") : args.length !== 0)
|
|
1170
|
-
throw new Error(help);
|
|
1171
|
-
const root = consumerRoot();
|
|
1172
|
-
if (command === "check") {
|
|
1173
|
-
check(root);
|
|
1174
|
-
return;
|
|
1175
|
-
}
|
|
1176
|
-
if (command === "status") {
|
|
1177
|
-
status(root);
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
await locked(`consumer:${root}`, async () => {
|
|
1181
|
-
recover(root);
|
|
1182
|
-
switch (command) {
|
|
1183
|
-
case "setup":
|
|
1184
|
-
setup(root, args[1]);
|
|
1185
|
-
break;
|
|
1186
|
-
case "local":
|
|
1187
|
-
await local(root);
|
|
1188
|
-
break;
|
|
1189
|
-
case "build":
|
|
1190
|
-
await build(root);
|
|
1191
|
-
break;
|
|
1192
|
-
case "npm":
|
|
1193
|
-
npm(root);
|
|
1194
|
-
break;
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
main().catch((error) => {
|
|
1199
|
-
console.error(`wq-switch: ${error.message}`);
|
|
1200
|
-
process.exitCode = 1;
|
|
1201
|
-
});
|
|
2
|
+
require('@webquark/tooling/wq-switch');
|