-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
152 lines (139 loc) · 4.1 KB
/
Copy pathbuild.ts
File metadata and controls
152 lines (139 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/// <reference lib="deno.ns" />
/**
* @file build.ts
* @description Build alternativo usando Deno.bundle API nativa (--unstable-bundle)
*/
import {
currentVersion,
incrementVersion,
listAssetsForCache,
parseArgs,
processBundleTarget,
} from "@syntaxmesh/utils/build";
import type { DenoBundleGlobalConfig, } from "@syntaxmesh/utils/interfaces";
// ============================================================================
// 📦 CONFIGURAÇÃO DECLARATIVA DE BUILDS
// ============================================================================
const CONFIG: DenoBundleGlobalConfig = {
ui: {
mode: "build",
default: true,
srcdir: "packages/ui/src",
distdir: "packages/server/build/dist",
publicdir: "packages/ui/public",
indexHtml: true,
clean: [".",],
entryPoints: ["app.tsx",],
platform: "browser",
format: "esm",
minify: false,
sourcemap: "linked",
keepNames: true,
codeSplitting: false,
packages: "bundle",
inlineImports: true,
},
workerdb: {
mode: "build",
default: true,
srcdir: "packages/worker-db/src",
distdir: "packages/server/build/dist",
clean: ["worker-db.js", "worker-db.js.map",],
entryPoints: ["worker.ts",],
outfile: "worker-db.js",
platform: "browser",
format: "esm",
minify: false,
sourcemap: "linked",
indexHtml: false,
keepNames: true,
codeSplitting: false,
packages: "bundle",
inlineImports: true,
},
sw: {
mode: "build",
default: true,
srcdir: "packages/service-worker/src",
distdir: "packages/server/build/dist",
clean: ["service-worker.js", "service-worker.js.map",],
entryPoints: ["service-worker.ts",],
platform: "browser",
format: "esm",
minify: false,
sourcemap: "linked",
indexHtml: false,
keepNames: true,
codeSplitting: false,
packages: "bundle",
inlineImports: true,
},
};
// ============================================================================
// 🚀 PIPELINE PRINCIPAL
// ============================================================================
const DENO_JSONC_PATH = "deno.jsonc";
async function build() {
const start = performance.now();
const { targets, globalNoVersion, watchTarget, } = parseArgs(
Deno.args,
CONFIG,
);
console.log(
"\n🚀 Iniciando Orquestrador de Build SyntaxMesh (Deno.bundle API)",
);
console.log(` 📦 Motor: Deno.bundle (nativo, --unstable-bundle)`,);
if (watchTarget) {
console.log(
`\n⚠️ AVISO: Modo Watch não suportado pelo Deno.bundle API.`,
);
console.log(` O alvo '${watchTarget}' foi ignorado.`,);
console.log(
` Para watch mode, use o build oficial: deno task build watch`,
);
console.log(
` (que utiliza esbuild com suporte a esbuild.context().watch())\n`,
);
Deno.exit(0,);
}
console.log(` 📋 Alvos: ${targets.join(", ",) || "(nenhum)"}`,);
console.log(` 🔒 Noversion: ${globalNoVersion}\n`,);
if (targets.length === 0) {
console.log("⚠️ Nenhum alvo para processar.",);
Deno.exit(0,);
}
try {
const currentVer = await currentVersion(DENO_JSONC_PATH,);
const finalVersion = globalNoVersion
? currentVer
: await incrementVersion(currentVer, DENO_JSONC_PATH,);
for (const targetName of targets) {
const targetConfig = CONFIG[targetName];
if (!targetConfig) {
console.warn(
`⚠️ Alvo '${targetName}' não encontrado no CONFIG. Pulando.`,
);
continue;
}
const listFn = targetName === "sw" ? listAssetsForCache : undefined;
await processBundleTarget(
targetName,
targetConfig,
finalVersion,
listFn,
);
}
console.log(`\n${"=".repeat(60,)}`,);
console.log(`🎉 ORQUESTRAÇÃO CONCLUÍDA COM SUCESSO!`,);
console.log(`${"=".repeat(60,)}`,);
} catch (error) {
console.error("\n🛑 Pipeline de build falhou:", error,);
Deno.exit(1,);
} finally {
const elapsed = (performance.now() - start).toFixed(0,);
console.log(`\n⏱️ Tempo total: ${elapsed}ms\n`,);
}
}
if (import.meta.main) {
await build();
}