@apps-in-toss/web-framework 0.0.6 → 0.0.7
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/chunk-DI2VGQ6M.js +53 -0
- package/dist/chunk-HL7M3JLX.js +53 -0
- package/dist/chunk-I3ZDGLIW.js +19 -0
- package/dist/chunk-LJBVSTWE.js +7687 -0
- package/dist/chunk-OMIGZ2S7.js +7689 -0
- package/dist/chunk-TZCMTMV7.js +38 -0
- package/dist/cli/index.cjs +644 -0
- package/dist/cli/index.d.cts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +592 -0
- package/dist/cli.cjs +613 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +562 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.cts +2 -0
- package/package.json +5 -5
- package/react-native/.bedrock/.env.js +4 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
__dirname,
|
|
4
|
+
__require,
|
|
5
|
+
loadConfig
|
|
6
|
+
} from "./chunk-HL7M3JLX.js";
|
|
7
|
+
|
|
8
|
+
// src/cli.ts
|
|
9
|
+
import { Cli } from "clipanion";
|
|
10
|
+
|
|
11
|
+
// src/BuildCommand/BuildCommand.ts
|
|
12
|
+
import { Command, Option } from "clipanion";
|
|
13
|
+
import picocolors from "picocolors";
|
|
14
|
+
|
|
15
|
+
// src/BuildCommand/build.ts
|
|
16
|
+
import fs from "fs";
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { createArtifact } from "@apps-in-toss/framework/cli-presets";
|
|
19
|
+
import * as mpack from "@react-native-bedrock/mpack-next";
|
|
20
|
+
import { statusPlugin } from "@react-native-bedrock/mpack-next/plugins";
|
|
21
|
+
import { execa } from "execa";
|
|
22
|
+
import presets from "react-native-bedrock/presets";
|
|
23
|
+
|
|
24
|
+
// src/utils/getPackageManager.ts
|
|
25
|
+
function getPackageManager({ isExecutor = false } = {}) {
|
|
26
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
27
|
+
const packageManagerCommands = {
|
|
28
|
+
npm: isExecutor ? "npx" : "npm",
|
|
29
|
+
pnpm: "pnpm",
|
|
30
|
+
yarn: "yarn"
|
|
31
|
+
};
|
|
32
|
+
if (!userAgent) {
|
|
33
|
+
return {
|
|
34
|
+
packageManager: packageManagerCommands["npm"],
|
|
35
|
+
version: "0.0.0"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const [packageManagerInfo] = userAgent.match(/(\w+)\/(\d+\.\d+\.\d+)/) || [];
|
|
39
|
+
const [packageManager, version2] = packageManagerInfo?.split("/") ?? ["npm", null];
|
|
40
|
+
if (!packageManager) {
|
|
41
|
+
return {
|
|
42
|
+
packageManager: packageManagerCommands["npm"],
|
|
43
|
+
version: "0.0.0"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
packageManager: packageManagerCommands[packageManager],
|
|
48
|
+
version: version2 ?? "0.0.0"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/BuildCommand/build.ts
|
|
53
|
+
async function build({ distDirname, cache }) {
|
|
54
|
+
const config = await loadConfig();
|
|
55
|
+
const rootDir = process.cwd();
|
|
56
|
+
const reactNativeProjectDir = path.resolve(__dirname, "..", "react-native");
|
|
57
|
+
const projectRootTmp = path.resolve(process.cwd(), ".bedrock");
|
|
58
|
+
await fs.promises.mkdir(projectRootTmp, { recursive: true });
|
|
59
|
+
await fs.promises.writeFile(
|
|
60
|
+
path.join(projectRootTmp, "metadata.json"),
|
|
61
|
+
JSON.stringify({ appName: config.appName, webPort: config.web.port })
|
|
62
|
+
);
|
|
63
|
+
const appName = config.appName;
|
|
64
|
+
const { packageManager } = getPackageManager({ isExecutor: true });
|
|
65
|
+
const distDir = path.join(rootDir, distDirname);
|
|
66
|
+
const webDistDir = path.join(distDir, "web");
|
|
67
|
+
await fs.promises.rm(distDir, { recursive: true, force: true });
|
|
68
|
+
await execa(packageManager, config.web.commands.build.split(" "), {
|
|
69
|
+
cwd: process.cwd(),
|
|
70
|
+
stdio: "inherit"
|
|
71
|
+
});
|
|
72
|
+
await fs.promises.mkdir(webDistDir, { recursive: true });
|
|
73
|
+
const items = await fs.promises.readdir(distDir);
|
|
74
|
+
for (const item of items) {
|
|
75
|
+
const src = path.join(distDir, item);
|
|
76
|
+
const dest = path.join(webDistDir, item);
|
|
77
|
+
if (src === webDistDir) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
await fs.promises.rename(src, dest);
|
|
81
|
+
}
|
|
82
|
+
const buildResults = await mpack.runBundle({
|
|
83
|
+
clean: false,
|
|
84
|
+
metafile: false,
|
|
85
|
+
dev: false,
|
|
86
|
+
rootDir: reactNativeProjectDir,
|
|
87
|
+
cache,
|
|
88
|
+
plugins: [statusPlugin],
|
|
89
|
+
config: {
|
|
90
|
+
appName,
|
|
91
|
+
services: {
|
|
92
|
+
sentry: {
|
|
93
|
+
enabled: false
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
concurrency: 2,
|
|
97
|
+
tasks: [
|
|
98
|
+
{
|
|
99
|
+
tag: `${appName}-ios`,
|
|
100
|
+
presets: [presets.service()],
|
|
101
|
+
build: {
|
|
102
|
+
babel: {
|
|
103
|
+
conditions: [(_code) => _code.includes("Ait")],
|
|
104
|
+
plugins: [
|
|
105
|
+
[
|
|
106
|
+
__require.resolve("@apps-in-toss/babel-plugin-json"),
|
|
107
|
+
{ jsonPath: "./.bedrock/metadata.json", identifierName: "Ait" }
|
|
108
|
+
]
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
platform: "ios",
|
|
112
|
+
entry: path.join(reactNativeProjectDir, "src", "_app.tsx"),
|
|
113
|
+
outfile: path.join(distDir, `${appName}.ios.js`)
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
tag: `${appName}-android`,
|
|
118
|
+
presets: [presets.service()],
|
|
119
|
+
build: {
|
|
120
|
+
babel: {
|
|
121
|
+
conditions: [(_code) => _code.includes("Ait")],
|
|
122
|
+
plugins: [
|
|
123
|
+
[
|
|
124
|
+
__require.resolve("@apps-in-toss/babel-plugin-json"),
|
|
125
|
+
{ jsonPath: "./.bedrock/metadata.json", identifierName: "Ait" }
|
|
126
|
+
]
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
platform: "android",
|
|
130
|
+
entry: path.join(reactNativeProjectDir, "src", "_app.tsx"),
|
|
131
|
+
outfile: path.join(distDir, `${appName}.android.js`)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
const artifactOutfile = await createArtifact({
|
|
138
|
+
buildResults,
|
|
139
|
+
rootDir,
|
|
140
|
+
reactNativeProjectDir,
|
|
141
|
+
webOutDir: webDistDir
|
|
142
|
+
});
|
|
143
|
+
if (!artifactOutfile) {
|
|
144
|
+
throw new Error("\uC544\uD2F0\uD329\uD2B8 \uC0DD\uC131\uC5D0 \uC2E4\uD328\uD588\uC5B4\uC694.");
|
|
145
|
+
}
|
|
146
|
+
return artifactOutfile;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/constants.ts
|
|
150
|
+
var APP_MANIFEST_NAME = "app.json";
|
|
151
|
+
var DEFAULT_DIST_DIR = "dist";
|
|
152
|
+
var API_BASE_URL = "https://apps-in-toss.toss.im/console";
|
|
153
|
+
var DEFAULT_LOCALHOST_PORT = 8081;
|
|
154
|
+
var DEFAULT_HOST = "localhost";
|
|
155
|
+
|
|
156
|
+
// src/BuildCommand/BuildCommand.ts
|
|
157
|
+
var BuildCommand = class extends Command {
|
|
158
|
+
static paths = [[`build`]];
|
|
159
|
+
static usage = Command.Usage({
|
|
160
|
+
category: "Build",
|
|
161
|
+
description: "Apps In Toss \uBE4C\uB4DC \uC544\uD2F0\uD329\uD2B8\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4",
|
|
162
|
+
examples: [["\uBE4C\uB4DC \uC544\uD2F0\uD329\uD2B8 \uC0DD\uC131\uD558\uAE30", "ait build"]]
|
|
163
|
+
});
|
|
164
|
+
cache = Option.Boolean("--cache", true);
|
|
165
|
+
async execute() {
|
|
166
|
+
const artifactOutfile = await build({
|
|
167
|
+
distDirname: DEFAULT_DIST_DIR,
|
|
168
|
+
cache: this.cache
|
|
169
|
+
});
|
|
170
|
+
console.log(`
|
|
171
|
+
${picocolors.blue(artifactOutfile)}
|
|
172
|
+
`);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/DeployCommand/DeployCommand.ts
|
|
177
|
+
import assert from "assert";
|
|
178
|
+
import path2 from "path";
|
|
179
|
+
import * as p from "@clack/prompts";
|
|
180
|
+
import { Command as Command2, Option as Option2 } from "clipanion";
|
|
181
|
+
import Debug2 from "debug";
|
|
182
|
+
import picocolors2 from "picocolors";
|
|
183
|
+
|
|
184
|
+
// src/DeployCommand/upload.ts
|
|
185
|
+
import * as fs2 from "fs";
|
|
186
|
+
import Debug from "debug";
|
|
187
|
+
var debug = Debug("cli:deploy");
|
|
188
|
+
async function uploadArtifact(config) {
|
|
189
|
+
debug("uploadArtifact", config);
|
|
190
|
+
const response = await fetch(
|
|
191
|
+
`${API_BASE_URL}/api-public/v3/appsintossconsole/bundles/${config.appName}/sandbox/upload`,
|
|
192
|
+
{
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: {
|
|
195
|
+
"Content-Type": "application/octet-stream",
|
|
196
|
+
"X-Ait-Console-Api-Key": config.apiKey
|
|
197
|
+
},
|
|
198
|
+
body: fs2.createReadStream(config.artifactPath),
|
|
199
|
+
duplex: "half"
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
return handleResponse(response);
|
|
203
|
+
}
|
|
204
|
+
async function handleResponse(response) {
|
|
205
|
+
debug(`Response ${response.status} ${response.statusText}`);
|
|
206
|
+
if (!response.ok) {
|
|
207
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
208
|
+
}
|
|
209
|
+
const data = await response.clone().json();
|
|
210
|
+
debug("uploadArtifact response", data);
|
|
211
|
+
if (data.resultType !== "SUCCESS") {
|
|
212
|
+
const errorCode = data?.error?.errorCode ?? "-1";
|
|
213
|
+
const errorReason = data?.error.reason ?? "unknown";
|
|
214
|
+
throw new Error(`${errorReason} (Code: ${errorCode})`);
|
|
215
|
+
}
|
|
216
|
+
const result = data.success;
|
|
217
|
+
return result.deploymentId;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/utils/readZipContent.ts
|
|
221
|
+
import yauzl from "yauzl";
|
|
222
|
+
function readZipContent(zipPath, fileName) {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
yauzl.open(zipPath, { lazyEntries: true }, (error, zipFile) => {
|
|
225
|
+
if (error) {
|
|
226
|
+
reject(error);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
zipFile.on("entry", (entry) => {
|
|
230
|
+
if (entry.fileName === fileName) {
|
|
231
|
+
zipFile.openReadStream(entry, (error2, readStream) => {
|
|
232
|
+
if (error2) {
|
|
233
|
+
throw error2;
|
|
234
|
+
}
|
|
235
|
+
let fileData = "";
|
|
236
|
+
readStream.on("data", (chunk) => fileData += chunk.toString("utf8")).on("end", () => {
|
|
237
|
+
zipFile.close();
|
|
238
|
+
resolve(fileData);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
zipFile.readEntry();
|
|
243
|
+
}
|
|
244
|
+
}).on("end", () => {
|
|
245
|
+
zipFile.close();
|
|
246
|
+
reject(new Error(`'${fileName}' not found in zip file`));
|
|
247
|
+
}).on("error", (error2) => {
|
|
248
|
+
zipFile.close();
|
|
249
|
+
reject(error2);
|
|
250
|
+
});
|
|
251
|
+
zipFile.readEntry();
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// src/DeployCommand/DeployCommand.ts
|
|
257
|
+
var debug2 = Debug2("cli:deploy");
|
|
258
|
+
var DeployCommand = class extends Command2 {
|
|
259
|
+
static paths = [["deploy"]];
|
|
260
|
+
apiKey = Option2.String("--api-key", {
|
|
261
|
+
required: false,
|
|
262
|
+
description: "\uC54C\uD30C \uBC30\uD3EC\uB97C \uC704\uD55C API \uD0A4"
|
|
263
|
+
});
|
|
264
|
+
async execute() {
|
|
265
|
+
const apiKey = this.apiKey || await p.password({
|
|
266
|
+
message: "\uC571\uC778\uD1A0\uC2A4 \uBC30\uD3EC API \uD0A4\uB97C \uC785\uB825\uD574\uC8FC\uC138\uC694",
|
|
267
|
+
validate: (value) => {
|
|
268
|
+
if (value.length === 0) {
|
|
269
|
+
return "API \uD0A4\uB294 \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.";
|
|
270
|
+
}
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
if (p.isCancel(apiKey)) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const artifactOutfile = await build({
|
|
279
|
+
distDirname: DEFAULT_DIST_DIR,
|
|
280
|
+
cache: false
|
|
281
|
+
});
|
|
282
|
+
const rootDir = process.cwd();
|
|
283
|
+
const resolvedArtifactPath = path2.resolve(rootDir, artifactOutfile);
|
|
284
|
+
const appIdentifier = await readZipContent(resolvedArtifactPath, APP_MANIFEST_NAME).then((rawAppManifest) => {
|
|
285
|
+
const appManifest = JSON.parse(rawAppManifest);
|
|
286
|
+
const appIdentifier2 = appManifest.appName;
|
|
287
|
+
assert(typeof appIdentifier2 === "string", "invalid appName");
|
|
288
|
+
return appIdentifier2;
|
|
289
|
+
}).catch((error) => {
|
|
290
|
+
debug2("invalid ait file", error);
|
|
291
|
+
throw new Error("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 ait \uD30C\uC77C\uC785\uB2C8\uB2E4");
|
|
292
|
+
});
|
|
293
|
+
let deploymentId = null;
|
|
294
|
+
const colorAppName = picocolors2.underline(picocolors2.cyan(appIdentifier));
|
|
295
|
+
await p.tasks([
|
|
296
|
+
{
|
|
297
|
+
title: `${colorAppName} \uC571 \uBC30\uD3EC \uC911...`,
|
|
298
|
+
task: async () => {
|
|
299
|
+
deploymentId = await uploadArtifact({
|
|
300
|
+
artifactPath: resolvedArtifactPath,
|
|
301
|
+
appName: appIdentifier,
|
|
302
|
+
apiKey
|
|
303
|
+
});
|
|
304
|
+
return `${colorAppName} \uBC30\uD3EC\uAC00 \uC644\uB8CC\uB418\uC5C8\uC5B4\uC694`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
]);
|
|
308
|
+
if (deploymentId) {
|
|
309
|
+
p.note(picocolors2.underline(picocolors2.green(`intoss-sandbox://${appIdentifier}?_deploymentId=${deploymentId}`)));
|
|
310
|
+
}
|
|
311
|
+
} catch (error) {
|
|
312
|
+
if (error instanceof Error) {
|
|
313
|
+
p.log.error(error.message);
|
|
314
|
+
} else {
|
|
315
|
+
console.error(error);
|
|
316
|
+
}
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/DevCommand/DevCommand.ts
|
|
323
|
+
import fs3 from "fs";
|
|
324
|
+
import path3 from "path";
|
|
325
|
+
import * as mpack2 from "@react-native-bedrock/mpack-next";
|
|
326
|
+
import { Command as Command3, Option as Option3 } from "clipanion";
|
|
327
|
+
import { execa as execa2 } from "execa";
|
|
328
|
+
import presets2 from "react-native-bedrock/presets";
|
|
329
|
+
var DevCommand = class extends Command3 {
|
|
330
|
+
static paths = [[`dev`]];
|
|
331
|
+
static usage = Command3.Usage({
|
|
332
|
+
category: "Development",
|
|
333
|
+
description: "AppsInToss \uAC1C\uBC1C \uC11C\uBC84\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4",
|
|
334
|
+
examples: [["\uAC1C\uBC1C \uC11C\uBC84 \uC2E4\uD589\uD558\uAE30", "ait dev"]]
|
|
335
|
+
});
|
|
336
|
+
host = Option3.String("--host");
|
|
337
|
+
port = Option3.String("--port");
|
|
338
|
+
async execute() {
|
|
339
|
+
const config = await loadConfig();
|
|
340
|
+
const serverOptions = {
|
|
341
|
+
host: this.host,
|
|
342
|
+
port: this.port ? parseInt(this.port, 10) : void 0
|
|
343
|
+
};
|
|
344
|
+
const cwd = path3.resolve(__dirname, "..", "react-native");
|
|
345
|
+
const projectRootTmp = path3.resolve(process.cwd(), ".bedrock");
|
|
346
|
+
await fs3.promises.mkdir(projectRootTmp, { recursive: true });
|
|
347
|
+
await fs3.promises.writeFile(
|
|
348
|
+
path3.join(projectRootTmp, "metadata.json"),
|
|
349
|
+
JSON.stringify({ appName: config.appName, webPort: config.web.port })
|
|
350
|
+
);
|
|
351
|
+
const appName = config.appName;
|
|
352
|
+
await mpack2.runServer({
|
|
353
|
+
host: serverOptions.host,
|
|
354
|
+
port: serverOptions.port,
|
|
355
|
+
enableEmbeddedReactDevTools: true,
|
|
356
|
+
enableRouterGen: false,
|
|
357
|
+
onServerReady: async () => {
|
|
358
|
+
this.context.stdout.write(
|
|
359
|
+
`Server is running on http://${serverOptions.host || DEFAULT_HOST}:${serverOptions.port || DEFAULT_LOCALHOST_PORT}
|
|
360
|
+
`
|
|
361
|
+
);
|
|
362
|
+
const { packageManager } = getPackageManager({ isExecutor: true });
|
|
363
|
+
await execa2(packageManager, config.web.commands.dev.split(" "), {
|
|
364
|
+
cwd: process.cwd(),
|
|
365
|
+
stdio: "inherit"
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
cwd,
|
|
369
|
+
config: {
|
|
370
|
+
appName,
|
|
371
|
+
services: {
|
|
372
|
+
sentry: {
|
|
373
|
+
enabled: false
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
devServer: {
|
|
377
|
+
presets: [presets2.service()],
|
|
378
|
+
build: {
|
|
379
|
+
entry: "./src/_app.tsx"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
tasks: []
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/InitCommand/InitCommand.ts
|
|
389
|
+
import fs5 from "fs";
|
|
390
|
+
import path5 from "path";
|
|
391
|
+
import * as p2 from "@clack/prompts";
|
|
392
|
+
import { Command as Command4 } from "clipanion";
|
|
393
|
+
import { kebabCase, merge } from "es-toolkit";
|
|
394
|
+
import { execa as execa3 } from "execa";
|
|
395
|
+
import yaml from "yaml";
|
|
396
|
+
|
|
397
|
+
// src/InitCommand/templates/index.tsx
|
|
398
|
+
var CONFIG_TEMPLATE = `import { defineConfig } from '@apps-in-toss/web-framework';
|
|
399
|
+
|
|
400
|
+
export default defineConfig({
|
|
401
|
+
appName: '%%appName%%',
|
|
402
|
+
web: {
|
|
403
|
+
port: %%webPort%%,
|
|
404
|
+
commands: {
|
|
405
|
+
dev: '%%webDevCommand%%',
|
|
406
|
+
build: '%%webBuildCommand%%',
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
`;
|
|
411
|
+
|
|
412
|
+
// src/utils/getPackageRoot.ts
|
|
413
|
+
import fs4 from "fs";
|
|
414
|
+
import path4 from "path";
|
|
415
|
+
function getPackageRoot() {
|
|
416
|
+
let cwd = process.cwd();
|
|
417
|
+
const root = path4.parse(cwd).root;
|
|
418
|
+
while (cwd !== root) {
|
|
419
|
+
if (fs4.existsSync(path4.join(cwd, "package.json"))) {
|
|
420
|
+
return cwd;
|
|
421
|
+
}
|
|
422
|
+
cwd = path4.dirname(cwd);
|
|
423
|
+
}
|
|
424
|
+
return cwd;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/utils/transformTemplate.ts
|
|
428
|
+
function transformTemplate(templateString, values) {
|
|
429
|
+
let result = templateString;
|
|
430
|
+
for (const key in values) {
|
|
431
|
+
const placeholder = `%%${key}%%`;
|
|
432
|
+
result = result.replace(new RegExp(placeholder, "g"), values[key]);
|
|
433
|
+
}
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/InitCommand/InitCommand.ts
|
|
438
|
+
var InitCommand = class extends Command4 {
|
|
439
|
+
static paths = [[`init`]];
|
|
440
|
+
async execute() {
|
|
441
|
+
const cwd = getPackageRoot();
|
|
442
|
+
p2.intro("\u{1F680} \uC571 \uCD08\uAE30\uD654\uB97C \uC2DC\uC791\uD569\uB2C8\uB2E4");
|
|
443
|
+
const appName = await p2.text({
|
|
444
|
+
message: "Enter app name",
|
|
445
|
+
validate: (value) => {
|
|
446
|
+
if (!value) {
|
|
447
|
+
return "\uC571 \uC774\uB984\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694";
|
|
448
|
+
}
|
|
449
|
+
const kebabCaseValue = kebabCase(value);
|
|
450
|
+
if (value !== kebabCaseValue) {
|
|
451
|
+
return `\uC571 \uC774\uB984\uC740 \uCF00\uBC25-\uCF00\uC774\uC2A4 \uD615\uC2DD\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4 (\uC608\uC2DC: ${kebabCaseValue})`;
|
|
452
|
+
}
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
if (p2.isCancel(appName)) {
|
|
457
|
+
p2.cancel("\uCD08\uAE30\uD654\uAC00 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
p2.log.step(`\uC571 \uC774\uB984\uC774 '${appName}'\uC73C\uB85C \uC124\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4`);
|
|
461
|
+
const webPort = await p2.text({
|
|
462
|
+
message: "Enter web port",
|
|
463
|
+
placeholder: "5173",
|
|
464
|
+
defaultValue: "5173"
|
|
465
|
+
});
|
|
466
|
+
if (p2.isCancel(webPort)) {
|
|
467
|
+
p2.cancel("\uCD08\uAE30\uD654\uAC00 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4");
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
p2.log.step("package.json \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC124\uC815\uD558\uB294 \uC911...");
|
|
471
|
+
const packageJson = await fs5.promises.readFile(path5.join(cwd, "package.json"), {
|
|
472
|
+
encoding: "utf-8"
|
|
473
|
+
});
|
|
474
|
+
const scripts = JSON.parse(packageJson);
|
|
475
|
+
const original = {
|
|
476
|
+
dev: scripts?.scripts?.dev || scripts?.scripts?.start,
|
|
477
|
+
build: scripts?.scripts?.build
|
|
478
|
+
};
|
|
479
|
+
scripts.scripts.dev = "ait dev";
|
|
480
|
+
scripts.scripts.build = "ait build";
|
|
481
|
+
scripts.scripts.deploy = "ait deploy";
|
|
482
|
+
await fs5.promises.writeFile(path5.join(cwd, "package.json"), JSON.stringify(scripts, null, 2), {
|
|
483
|
+
encoding: "utf-8"
|
|
484
|
+
});
|
|
485
|
+
p2.log.step("apps-in-toss.config.web.ts \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
486
|
+
const config = transformTemplate(CONFIG_TEMPLATE, {
|
|
487
|
+
appName,
|
|
488
|
+
webPort,
|
|
489
|
+
webDevCommand: original.dev === "ait dev" ? "" : original.dev,
|
|
490
|
+
webBuildCommand: original.build === "ait build" ? "" : original.build
|
|
491
|
+
});
|
|
492
|
+
await fs5.promises.writeFile(path5.join(cwd, "apps-in-toss.config.web.ts"), config, {
|
|
493
|
+
encoding: "utf-8"
|
|
494
|
+
});
|
|
495
|
+
p2.log.step(".gitignore \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
|
|
496
|
+
await fs5.promises.appendFile(path5.join(cwd, ".gitignore"), "\n.bedrock\n");
|
|
497
|
+
p2.log.step("app.json \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uB294 \uC911...");
|
|
498
|
+
await fs5.promises.writeFile(
|
|
499
|
+
path5.join(cwd, "app.json"),
|
|
500
|
+
JSON.stringify({
|
|
501
|
+
clientId: "",
|
|
502
|
+
appName,
|
|
503
|
+
permissions: []
|
|
504
|
+
}),
|
|
505
|
+
{
|
|
506
|
+
encoding: "utf-8"
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
const isPnP = fs5.existsSync(path5.join(cwd, ".pnp.cjs"));
|
|
510
|
+
if (isPnP) {
|
|
511
|
+
const yarnrcPath = path5.join(cwd, ".yarnrc.yml");
|
|
512
|
+
let yarnrc = {};
|
|
513
|
+
try {
|
|
514
|
+
const yarnrcContent = await fs5.promises.readFile(yarnrcPath, { encoding: "utf-8" });
|
|
515
|
+
yarnrc = yaml.parse(yarnrcContent);
|
|
516
|
+
} catch {
|
|
517
|
+
p2.log.info(".yarnrc.yml \uD30C\uC77C\uC774 \uC5C6\uC5B4 \uC0C8\uB85C \uC0DD\uC131\uD569\uB2C8\uB2E4.");
|
|
518
|
+
}
|
|
519
|
+
p2.log.step(".yarnrc.yml \uD30C\uC77C\uC744 \uC5C5\uB370\uC774\uD2B8\uD558\uB294 \uC911...");
|
|
520
|
+
yarnrc.packageExtensions = merge(yarnrc.packageExtensions, {
|
|
521
|
+
"@react-native-community/cli-debugger-ui@*": {
|
|
522
|
+
dependencies: {
|
|
523
|
+
"@babel/runtime": "^7"
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
"react-native-video@*": {
|
|
527
|
+
peerDependencies: {
|
|
528
|
+
react: "*",
|
|
529
|
+
"react-native": "*"
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
"react-native-fast-image@*": {
|
|
533
|
+
dependencies: {
|
|
534
|
+
"@babel/runtime": "^7"
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
await fs5.promises.writeFile(yarnrcPath, yaml.stringify(yarnrc), { encoding: "utf-8" });
|
|
539
|
+
await execa3("yarn", ["install"], {
|
|
540
|
+
cwd,
|
|
541
|
+
stdio: "inherit"
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
p2.outro("\u2728 \uCD08\uAE30\uD654\uAC00 \uC644\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4!");
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// package.json
|
|
549
|
+
var version = "0.1.6-next.6";
|
|
550
|
+
|
|
551
|
+
// src/cli.ts
|
|
552
|
+
var cli = new Cli({
|
|
553
|
+
binaryLabel: "apps-in-toss",
|
|
554
|
+
binaryName: "apps-in-toss",
|
|
555
|
+
binaryVersion: version,
|
|
556
|
+
enableCapture: true
|
|
557
|
+
});
|
|
558
|
+
cli.register(InitCommand);
|
|
559
|
+
cli.register(DevCommand);
|
|
560
|
+
cli.register(BuildCommand);
|
|
561
|
+
cli.register(DeployCommand);
|
|
562
|
+
cli.runExit(process.argv.slice(2));
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
package/dist/index.d.cts
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"description": "Web Framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"vitest": "^3.0.5"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@apps-in-toss/babel-plugin-json": "0.0.
|
|
52
|
-
"@apps-in-toss/cli": "0.0.
|
|
53
|
-
"@apps-in-toss/framework": "0.0.
|
|
51
|
+
"@apps-in-toss/babel-plugin-json": "0.0.7",
|
|
52
|
+
"@apps-in-toss/cli": "0.0.7",
|
|
53
|
+
"@apps-in-toss/framework": "0.0.7",
|
|
54
54
|
"@babel/core": "7.23.9",
|
|
55
55
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
56
56
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "66c7ad26e7180aec19b4c6ab168c638708997aff"
|
|
80
80
|
}
|