@apps-in-toss/web-framework 0.0.0-dev.1739241377950

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