@tamagui/cli 2.0.0-rc.26 → 2.0.0-rc.26-1773452370596

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/cli",
3
- "version": "2.0.0-rc.26",
3
+ "version": "2.0.0-rc.26-1773452370596",
4
4
  "bin": {
5
5
  "tama": "./dist/index.cjs",
6
6
  "tamagui": "./dist/index.cjs"
@@ -26,11 +26,11 @@
26
26
  "test:web": "bun run test"
27
27
  },
28
28
  "dependencies": {
29
- "@tamagui/create-theme": "2.0.0-rc.26",
30
- "@tamagui/generate-themes": "2.0.0-rc.26",
31
- "@tamagui/static": "2.0.0-rc.26",
32
- "@tamagui/types": "2.0.0-rc.26",
33
- "@tamagui/vite-plugin": "2.0.0-rc.26",
29
+ "@tamagui/create-theme": "2.0.0-rc.26-1773452370596",
30
+ "@tamagui/generate-themes": "2.0.0-rc.26-1773452370596",
31
+ "@tamagui/static": "2.0.0-rc.26-1773452370596",
32
+ "@tamagui/types": "2.0.0-rc.26-1773452370596",
33
+ "@tamagui/vite-plugin": "2.0.0-rc.26-1773452370596",
34
34
  "arg": "^5.0.2",
35
35
  "chalk": "^4.1.2",
36
36
  "change-case": "^4.1.2",
@@ -49,7 +49,7 @@
49
49
  "url": "^0.11.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@tamagui/build": "2.0.0-rc.26",
52
+ "@tamagui/build": "2.0.0-rc.26-1773452370596",
53
53
  "@types/chokidar": "^2.1.3",
54
54
  "@types/marked": "^5.0.0",
55
55
  "vitest": "4.0.4"
package/dist/add.js DELETED
@@ -1,91 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var add_exports = {};
24
- __export(add_exports, {
25
- generatedPackageTypes: () => generatedPackageTypes,
26
- installGeneratedPackage: () => installGeneratedPackage
27
- });
28
- module.exports = __toCommonJS(add_exports);
29
- var import_node_child_process = require("node:child_process"), import_node_fs = require("node:fs"), import_promises = require("node:fs/promises"), import_node_os = require("node:os"), import_node_path = __toESM(require("node:path")), import_chalk = __toESM(require("chalk")), import_change_case = require("change-case"), import_fs_extra = require("fs-extra"), import_marked = require("marked"), import_marked_terminal = __toESM(require("marked-terminal")), import_opener = __toESM(require("opener")), import_prompts = __toESM(require("prompts"));
30
- import_marked.marked.setOptions({
31
- renderer: new import_marked_terminal.default()
32
- });
33
- const home = (0, import_node_os.homedir)(), tamaguiDir = import_node_path.default.join(home, ".tamagui"), generatedPackageTypes = ["font", "icon"], installGeneratedPackage = async (type, packagesPath) => {
34
- if (packagesPath = packagesPath || import_node_path.default.join(process.cwd(), "packages"), !generatedPackageTypes.includes(type))
35
- throw new Error(
36
- `${type ? `Type "${type}" is Not supported.` : "No type provided."} Supported types: ${generatedPackageTypes.join(", ")}`
37
- );
38
- const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
39
- console.info(`Setting up ${import_chalk.default.blueBright(tamaguiDir)}...`), await (0, import_fs_extra.ensureDir)(tamaguiDir);
40
- const tempDir = import_node_path.default.join(tamaguiDir, repoName);
41
- (0, import_node_fs.existsSync)(tempDir) && (0, import_node_fs.rmSync)(tempDir, { recursive: !0 });
42
- try {
43
- process.chdir(tamaguiDir);
44
- try {
45
- console.info("Attempting to clone with SSH"), (0, import_node_child_process.execSync)(
46
- `git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`
47
- );
48
- } catch {
49
- console.info("SSH failed - Attempting to c lone with HTTPS"), (0, import_node_child_process.execSync)(
50
- `git clone -n --depth=1 --branch generated --filter=tree:0 https://github.com/tamagui/${repoName}`
51
- );
52
- }
53
- process.chdir(tempDir), (0, import_node_child_process.execSync)(["git sparse-checkout set --no-cone meta", "git checkout"].join(" && "));
54
- } catch (error) {
55
- if (error instanceof Error)
56
- throw error?.stderr.includes("Repository not found") && (console.info(
57
- import_chalk.default.yellow(
58
- `You don't have access to Tamagui ${type === "font" ? "fonts" : "icons"}. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`
59
- )
60
- ), (0, import_opener.default)("https://tamagui.dev/takeout"), process.exit(0)), error;
61
- }
62
- const meta = JSON.parse(
63
- await (0, import_promises.readFile)(import_node_path.default.join(tamaguiDir, repoName, "meta", "data.json")).then(
64
- (r) => r.toString()
65
- )
66
- );
67
- console.info(
68
- import_chalk.default.gray(
69
- "Use \u21E7/\u21E9 to navigate. Use tab to cycle the result. Use Page Up/Page Down (on Mac: fn + \u21E7 / \u21E9) to change page. Hit enter to select the highlighted item below the prompt."
70
- )
71
- );
72
- const result = await (0, import_prompts.default)({
73
- name: "packageName",
74
- type: "autocomplete",
75
- message: type === "icon" ? "Pick an icon pack:" : type === "font" ? "Pick a font:" : "Pick one:",
76
- choices: Object.entries(meta).map(([slug, data]) => ({
77
- title: type === "font" ? `${slug}: ${data.weights.length} weights, ${data.styles.length} styles, ${data.subsets.length} subsets (https://fonts.google.com/specimen/${(0, import_change_case.pascalCase)(slug)})` : `${data.name}: ${data.total} icons, ${data.license.title} license (${data.author.url})`,
78
- value: slug
79
- }))
80
- }), packageName = `${type}-${result.packageName}`, packageDir = import_node_path.default.join(tempDir, "packages", packageName);
81
- process.chdir(tempDir), (0, import_node_child_process.execSync)(
82
- [`git sparse-checkout set --no-cone packages/${packageName}`, "git checkout"].join(
83
- " && "
84
- )
85
- );
86
- const finalDir = import_node_path.default.join(packagesPath, packageName);
87
- await (0, import_fs_extra.ensureDir)(packagesPath), await (0, import_fs_extra.copy)(packageDir, finalDir), console.info(), console.info(import_chalk.default.green(`Created the package under ${finalDir}`)), console.info();
88
- const readmePath = import_node_path.default.join(finalDir, "README.md");
89
- (0, import_node_fs.existsSync)(readmePath) && console.info(import_marked.marked.parse((0, import_fs_extra.readFileSync)(readmePath).toString()));
90
- };
91
- //# sourceMappingURL=add.js.map
package/dist/add.js.map DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/add.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAyB,+BACzB,iBAAmC,oBACnC,kBAAyB,6BACzB,iBAAwB,oBACxB,mBAAiB,+BAEjB,eAAkB,2BAClB,qBAA2B,wBAC3B,kBAA8C,qBAC9C,gBAAuB,mBACvB,yBAA6B,qCAC7B,gBAAiB,4BACjB,iBAAoB;AAEpB,qBAAO,WAAW;AAAA,EAChB,UAAU,IAAI,uBAAAA,QAAiB;AACjC,CAAC;AAED,MAAM,WAAO,wBAAQ,GACf,aAAa,iBAAAC,QAAK,KAAK,MAAM,UAAU,GAEhC,wBAAwB,CAAC,QAAQ,MAAM,GACvC,0BAA0B,OAAO,MAAc,iBAA0B;AAEpF,MADA,e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;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,UAAM,eAAAE,SAAQ;AAAA,IAC3B,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE,SAAS,SACL,uBACA,SAAS,SACP,iBACA;AAAA,IACR,SAAS,OAAO,QAAa,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO;AAAA,MACxD,OACE,SAAS,SACL,GAAG,IAAI,KAAK,KAAK,QAAQ,MAAM,aAAa,KAAK,OAAO,MAAM,YAC5D,KAAK,QAAQ,MACf,mDAA+C,+BAAW,IAAI,CAAC,MAC/D,GAAG,KAAK,IAAI,KAAK,KAAK,KAAK,WAAW,KAAK,QAAQ,KAAK,aAAa,KAAK,OAAO,GAAG;AAAA,MAC1F,OAAO;AAAA,IACT,EAAE;AAAA,EACJ,CAAC,GAEK,cAAc,GAAG,IAAI,IAAI,OAAO,WAAW,IAC3C,aAAa,iBAAAH,QAAK,KAAK,SAAS,YAAY,WAAW;AAC7D,UAAQ,MAAM,OAAO,OACrB;AAAA,IACE,CAAC,8CAA8C,WAAW,IAAI,cAAc,EAAE;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,iBAAAA,QAAK,KAAK,cAAc,WAAW;AACpD,YAAM,2BAAU,YAAY,GAC5B,UAAM,sBAAK,YAAY,QAAQ,GAE/B,QAAQ,KAAK,GACb,QAAQ,KAAK,aAAAC,QAAM,MAAM,6BAA6B,QAAQ,EAAE,CAAC,GACjE,QAAQ,KAAK;AAEb,QAAM,aAAa,iBAAAD,QAAK,KAAK,UAAU,WAAW;AAClD,MAAI,2BAAW,UAAU,KACvB,QAAQ,KAAK,qBAAO,UAAM,8BAAa,UAAU,EAAE,SAAS,CAAC,CAAC;AAElE;",
5
- "names": ["TerminalRenderer", "path", "chalk", "open", "prompts"]
6
- }
package/dist/build.js DELETED
@@ -1,240 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var build_exports = {};
24
- __export(build_exports, {
25
- build: () => build,
26
- insertCssImport: () => insertCssImport
27
- });
28
- module.exports = __toCommonJS(build_exports);
29
- var import_static = require("@tamagui/static"), import_chokidar = __toESM(require("chokidar")), import_fs_extra = require("fs-extra"), import_micromatch = __toESM(require("micromatch")), import_node_path = require("node:path"), import_node_os = require("node:os"), import_node_child_process = require("node:child_process"), import_node_crypto = require("node:crypto");
30
- function insertCssImport(jsContent, cssImport) {
31
- const directiveMatch = jsContent.match(/^(['"])use (client|server)\1;?\n?/);
32
- if (directiveMatch) {
33
- const directive = directiveMatch[0], rest = jsContent.slice(directive.length);
34
- return `${directive}${cssImport}
35
- ${rest}`;
36
- }
37
- return `${cssImport}
38
- ${jsContent}`;
39
- }
40
- const build = async (options) => {
41
- const sourceDir = options.dir ?? ".", outputDir = options.output, outputAround = options.outputAround || !1, promises = [], isDryRun = options.dryRun || !1;
42
- isDryRun && console.info(`[dry-run] no files will be written
43
- `), outputDir && await (0, import_fs_extra.mkdir)(outputDir, { recursive: !0 });
44
- const loadedOptions = (0, import_static.loadTamaguiBuildConfigSync)(options.tamaguiOptions);
45
- loadedOptions.disable && console.warn(
46
- '[tamagui] Note: "disable" option in tamagui.build.ts is being ignored for CLI build command'
47
- );
48
- const buildOptions = {
49
- ...loadedOptions,
50
- disable: !1,
51
- disableExtraction: !1
52
- }, targets = options.target === "both" || !options.target ? ["web", "native"] : [options.target], webTamaguiOptions = {
53
- ...buildOptions,
54
- platform: "web"
55
- };
56
- await (0, import_static.loadTamagui)(webTamaguiOptions);
57
- const allFiles = [], watchPattern = sourceDir.match(/\.(tsx|jsx)$/) ? sourceDir : `${sourceDir}/**/*.{tsx,jsx}`;
58
- await new Promise((res) => {
59
- const watcher = import_chokidar.default.watch(watchPattern, {
60
- ignoreInitial: !1
61
- });
62
- watcher.on("add", (relativePath) => {
63
- const sourcePath = (0, import_node_path.resolve)(process.cwd(), relativePath);
64
- options.exclude && import_micromatch.default.contains(relativePath, options.exclude) || options.include && !import_micromatch.default.contains(relativePath, options.include) || allFiles.push(sourcePath);
65
- }).on("ready", () => {
66
- watcher.close().then(() => res());
67
- });
68
- });
69
- const fileToTargets = /* @__PURE__ */ new Map();
70
- for (const sourcePath of allFiles) {
71
- const platformMatch = sourcePath.match(/\.(web|native|ios|android)\.(tsx|jsx)$/);
72
- let filePlatforms = [];
73
- if (platformMatch) {
74
- const platform = platformMatch[1];
75
- platform === "web" ? filePlatforms = ["web"] : (platform === "native" || platform === "ios" || platform === "android") && (filePlatforms = ["native"]);
76
- } else {
77
- const basePath = sourcePath.replace(/\.(tsx|jsx)$/, ""), hasNative = allFiles.some(
78
- (f) => f === `${basePath}.native.tsx` || f === `${basePath}.native.jsx` || f === `${basePath}.ios.tsx` || f === `${basePath}.ios.jsx` || f === `${basePath}.android.tsx` || f === `${basePath}.android.jsx`
79
- ), hasWeb = allFiles.some(
80
- (f) => f === `${basePath}.web.tsx` || f === `${basePath}.web.jsx`
81
- );
82
- filePlatforms = targets.filter((target) => !(target === "native" && hasNative || target === "web" && hasWeb)), hasWeb && hasNative && (filePlatforms = []);
83
- }
84
- filePlatforms.length > 0 && fileToTargets.set(sourcePath, filePlatforms);
85
- }
86
- const stats = {
87
- filesProcessed: 0,
88
- optimized: 0,
89
- flattened: 0,
90
- styled: 0,
91
- found: 0
92
- }, trackedFiles = [], restoreDir = options.runCommand ? (0, import_node_path.join)((0, import_node_os.tmpdir)(), `tamagui-restore-${process.pid}`) : null;
93
- restoreDir && await (0, import_fs_extra.mkdir)(restoreDir, { recursive: !0 });
94
- const trackFile = async (filePath) => {
95
- if (!restoreDir) return;
96
- const hash = (0, import_node_crypto.createHash)("md5").update(filePath).digest("hex"), backupPath = (0, import_node_path.join)(restoreDir, hash);
97
- await (0, import_fs_extra.copyFile)(filePath, backupPath), trackedFiles.push({ path: filePath, hardlinkPath: backupPath, mtimeAfterWrite: 0 });
98
- }, recordMtime = async (filePath) => {
99
- if (!restoreDir) return;
100
- const tracked = trackedFiles.find((t) => t.path === filePath);
101
- if (tracked) {
102
- const fileStat = await (0, import_fs_extra.stat)(filePath);
103
- tracked.mtimeAfterWrite = fileStat.mtimeMs;
104
- }
105
- };
106
- for (const [sourcePath, filePlatforms] of fileToTargets)
107
- promises.push(
108
- (async () => {
109
- options.debug && (process.env.NODE_ENV ||= "development");
110
- const originalSource = await (0, import_fs_extra.readFile)(sourcePath, "utf-8");
111
- if (isDryRun && console.info(`
112
- ${sourcePath} [${filePlatforms.join(", ")}]`), filePlatforms.includes("web")) {
113
- process.env.TAMAGUI_TARGET = "web";
114
- const extractor = (0, import_static.createExtractor)({
115
- platform: "web"
116
- }), out = await (0, import_static.extractToClassNames)({
117
- extractor,
118
- source: originalSource,
119
- sourcePath,
120
- options: {
121
- ...buildOptions,
122
- platform: "web"
123
- },
124
- shouldPrintDebug: options.debug || !1
125
- });
126
- if (out)
127
- if (stats.filesProcessed++, stats.optimized += out.stats.optimized, stats.flattened += out.stats.flattened, stats.styled += out.stats.styled, stats.found += out.stats.found, isDryRun) {
128
- const jsContent = typeof out.js == "string" ? out.js : out.js.toString("utf-8");
129
- out.styles && console.info(`
130
- css:
131
- ${out.styles}`), console.info(`
132
- js:
133
- ${jsContent}`);
134
- } else {
135
- const relPath = outputDir ? (0, import_node_path.relative)((0, import_node_path.resolve)(sourceDir), sourcePath) : (0, import_node_path.basename)(sourcePath), cssName = "_" + (0, import_node_path.basename)(sourcePath, (0, import_node_path.extname)(sourcePath)), outputBase = outputDir ? (0, import_node_path.join)(outputDir, (0, import_node_path.dirname)(relPath)) : (0, import_node_path.dirname)(sourcePath);
136
- outputDir && await (0, import_fs_extra.mkdir)(outputBase, { recursive: !0 });
137
- const stylePath = (0, import_node_path.join)(outputBase, cssName + ".css"), cssImport = `import "./${cssName}.css"`, jsContent = typeof out.js == "string" ? out.js : out.js.toString("utf-8"), code = insertCssImport(jsContent, cssImport), webOutputPath = outputDir ? (0, import_node_path.join)(outputDir, relPath) : sourcePath;
138
- outputDir || await trackFile(sourcePath), await (0, import_fs_extra.writeFile)(webOutputPath, code, "utf-8"), outputDir || await recordMtime(sourcePath), await (0, import_fs_extra.writeFile)(stylePath, out.styles, "utf-8"), outputDir || trackedFiles.push({
139
- path: stylePath,
140
- hardlinkPath: "",
141
- // Empty means delete on restore
142
- mtimeAfterWrite: (await (0, import_fs_extra.stat)(stylePath)).mtimeMs
143
- });
144
- }
145
- else isDryRun && console.info(" web: no output");
146
- }
147
- if (filePlatforms.includes("native")) {
148
- process.env.TAMAGUI_TARGET = "native";
149
- const nativeTamaguiOptions = {
150
- ...buildOptions,
151
- platform: "native"
152
- }, nativeOut = (0, import_static.extractToNative)(
153
- sourcePath,
154
- originalSource,
155
- nativeTamaguiOptions
156
- );
157
- if (isDryRun)
158
- nativeOut.code ? console.info(`
159
- native:
160
- ${nativeOut.code}`) : console.info(" native: no output");
161
- else {
162
- let nativeOutputPath = sourcePath;
163
- const needsNativeSuffix = !/\.(web|native|ios|android)\.(tsx|jsx)$/.test(
164
- sourcePath
165
- ) && (filePlatforms.length > 1 || outputAround);
166
- if (outputAround) {
167
- if (nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, ".native.$1"), await (0, import_fs_extra.stat)(nativeOutputPath).catch(() => null))
168
- throw new Error(
169
- `--output-around: ${nativeOutputPath} already exists. Remove it first or use --output instead.`
170
- );
171
- } else if (outputDir) {
172
- const relPath = (0, import_node_path.relative)((0, import_node_path.resolve)(sourceDir), sourcePath), outputRelPath = needsNativeSuffix ? relPath.replace(/\.(tsx|jsx)$/, ".native.$1") : relPath;
173
- nativeOutputPath = (0, import_node_path.join)(outputDir, outputRelPath), await (0, import_fs_extra.mkdir)((0, import_node_path.dirname)(nativeOutputPath), { recursive: !0 });
174
- } else needsNativeSuffix && (nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, ".native.$1"));
175
- if (nativeOut.code) {
176
- if (nativeOut.code.includes("__ReactNativeStyleSheet") || nativeOut.code.includes("_withStableStyle")) {
177
- stats.filesProcessed++;
178
- const wrapperMatches = nativeOut.code.match(/_withStableStyle/g);
179
- wrapperMatches && (stats.flattened += wrapperMatches.length);
180
- }
181
- !outputDir && !outputAround && (nativeOutputPath === sourcePath || filePlatforms.length === 1) && await trackFile(nativeOutputPath), await (0, import_fs_extra.writeFile)(nativeOutputPath, nativeOut.code, "utf-8"), !outputDir && !outputAround && await recordMtime(nativeOutputPath), !outputDir && !outputAround && nativeOutputPath !== sourcePath && filePlatforms.length > 1 && trackedFiles.push({
182
- path: nativeOutputPath,
183
- hardlinkPath: "",
184
- // Empty = delete on restore
185
- mtimeAfterWrite: (await (0, import_fs_extra.stat)(nativeOutputPath)).mtimeMs
186
- }), outputAround && console.info(` \u2192 ${nativeOutputPath}`);
187
- }
188
- }
189
- }
190
- })()
191
- );
192
- if (await Promise.all(promises), isDryRun && console.info(
193
- `
194
- ${stats.filesProcessed} files | ${stats.found} found | ${stats.optimized} optimized | ${stats.flattened} flattened | ${stats.styled} styled
195
- `
196
- ), options.expectOptimizations !== void 0) {
197
- const totalOptimizations = stats.optimized + stats.flattened;
198
- totalOptimizations < options.expectOptimizations && (console.error(
199
- `
200
- Expected at least ${options.expectOptimizations} optimizations but only got ${totalOptimizations}`
201
- ), console.error(`Stats: ${JSON.stringify(stats, null, 2)}`), process.exit(1)), console.info(
202
- `
203
- \u2713 Met optimization target: ${totalOptimizations} >= ${options.expectOptimizations}`
204
- );
205
- }
206
- if (options.runCommand && options.runCommand.length > 0) {
207
- const command = options.runCommand.join(" ");
208
- console.info(`
209
- Running: ${command}
210
- `);
211
- try {
212
- (0, import_node_child_process.execSync)(command, { stdio: "inherit" });
213
- } catch (err) {
214
- console.error(`
215
- Command failed with exit code ${err.status || 1}`), process.exitCode = err.status || 1;
216
- } finally {
217
- await restoreFiles(trackedFiles, restoreDir);
218
- }
219
- }
220
- return { stats, trackedFiles };
221
- };
222
- async function restoreFiles(trackedFiles, restoreDir) {
223
- if (!restoreDir || trackedFiles.length === 0) return;
224
- console.info(`
225
- Restoring ${trackedFiles.length} files...`);
226
- let restored = 0, skipped = 0, deleted = 0;
227
- for (const tracked of trackedFiles)
228
- try {
229
- const currentStat = await (0, import_fs_extra.stat)(tracked.path).catch(() => null);
230
- if (currentStat && currentStat.mtimeMs !== tracked.mtimeAfterWrite) {
231
- console.warn(` Skipping ${tracked.path} - modified during build`), skipped++;
232
- continue;
233
- }
234
- tracked.hardlinkPath === "" ? (await (0, import_fs_extra.rm)(tracked.path, { force: !0 }), deleted++) : (await (0, import_fs_extra.copyFile)(tracked.hardlinkPath, tracked.path), restored++);
235
- } catch (err) {
236
- console.warn(` Failed to restore ${tracked.path}: ${err.message}`), skipped++;
237
- }
238
- await (0, import_fs_extra.rm)(restoreDir, { recursive: !0, force: !0 }), console.info(` Restored: ${restored}, Deleted: ${deleted}, Skipped: ${skipped}`);
239
- }
240
-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