@capgo/cli 4.6.0 → 4.6.2
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/CHANGELOG.md +14 -0
- package/dist/index.js +106 -15
- package/package.json +1 -1
- package/src/init.ts +41 -15
- package/src/utils.ts +85 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.6.2](https://github.com/Cap-go/CLI/compare/v4.6.1...v4.6.2) (2024-05-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* better handle nuxt and nextjs ([7f9c0a0](https://github.com/Cap-go/CLI/commit/7f9c0a04ac5097b5ea7b9b9edb0dc815e43ca2e7))
|
|
11
|
+
|
|
12
|
+
### [4.6.1](https://github.com/Cap-go/CLI/compare/v4.6.0...v4.6.1) (2024-05-08)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* force encryption when init and exist ([f6be928](https://github.com/Cap-go/CLI/commit/f6be9281dc8e978fc1a7e80174a884c50d46c495))
|
|
18
|
+
|
|
5
19
|
## [4.6.0](https://github.com/Cap-go/CLI/compare/v4.5.0...v4.6.0) (2024-05-08)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.js
CHANGED
|
@@ -92373,7 +92373,7 @@ var {
|
|
|
92373
92373
|
// package.json
|
|
92374
92374
|
var package_default = {
|
|
92375
92375
|
name: "@capgo/cli",
|
|
92376
|
-
version: "4.6.
|
|
92376
|
+
version: "4.6.2",
|
|
92377
92377
|
description: "A CLI to upload to capgo servers",
|
|
92378
92378
|
author: "github.com/riderx",
|
|
92379
92379
|
license: "Apache 2.0",
|
|
@@ -93770,6 +93770,72 @@ async function* getFiles(dir) {
|
|
|
93770
93770
|
yield res;
|
|
93771
93771
|
}
|
|
93772
93772
|
}
|
|
93773
|
+
async function findProjectType() {
|
|
93774
|
+
const pwd = import_node_process8.default.cwd();
|
|
93775
|
+
for await (const f3 of getFiles(pwd)) {
|
|
93776
|
+
if (f3.includes("angular.json")) {
|
|
93777
|
+
f2.info("Found angular project");
|
|
93778
|
+
return "angular";
|
|
93779
|
+
}
|
|
93780
|
+
if (f3.includes("nuxt.config.js")) {
|
|
93781
|
+
f2.info("Found nuxtjs project");
|
|
93782
|
+
return "nuxtjs";
|
|
93783
|
+
}
|
|
93784
|
+
if (f3.includes("next.config.js")) {
|
|
93785
|
+
f2.info("Found nextjs project");
|
|
93786
|
+
return "nextjs";
|
|
93787
|
+
}
|
|
93788
|
+
if (f3.includes("svelte.config.js")) {
|
|
93789
|
+
f2.info("Found sveltekit project");
|
|
93790
|
+
return "sveltekit";
|
|
93791
|
+
}
|
|
93792
|
+
}
|
|
93793
|
+
return "unknown";
|
|
93794
|
+
}
|
|
93795
|
+
async function findMainFileForProjectType(projectType) {
|
|
93796
|
+
if (projectType === "angular")
|
|
93797
|
+
return "src/main.ts";
|
|
93798
|
+
if (projectType === "nuxtjs")
|
|
93799
|
+
return "src/main.ts";
|
|
93800
|
+
if (projectType === "nextjs")
|
|
93801
|
+
return "pages/_app.tsx";
|
|
93802
|
+
if (projectType === "sveltekit")
|
|
93803
|
+
return "src/main.ts";
|
|
93804
|
+
return null;
|
|
93805
|
+
}
|
|
93806
|
+
async function findBuildCommandForProjectType(projectType) {
|
|
93807
|
+
if (projectType === "angular") {
|
|
93808
|
+
f2.info("Angular project detected");
|
|
93809
|
+
return "build";
|
|
93810
|
+
}
|
|
93811
|
+
if (projectType === "nuxtjs") {
|
|
93812
|
+
f2.info("Nuxtjs project detected");
|
|
93813
|
+
return "generate";
|
|
93814
|
+
}
|
|
93815
|
+
if (projectType === "nextjs") {
|
|
93816
|
+
f2.info("Nextjs project detected");
|
|
93817
|
+
f2.warn("Please make sure you have configured static export in your next.config.js: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports");
|
|
93818
|
+
f2.warn("Please make sure you have the output: 'export' and distDir: 'dist' in your next.config.js");
|
|
93819
|
+
const doContinue = await se({ message: "Do you want to continue?" });
|
|
93820
|
+
if (!doContinue) {
|
|
93821
|
+
f2.error("Aborted");
|
|
93822
|
+
program.error("");
|
|
93823
|
+
}
|
|
93824
|
+
return "build";
|
|
93825
|
+
}
|
|
93826
|
+
if (projectType === "sveltekit") {
|
|
93827
|
+
f2.info("Sveltekit project detected");
|
|
93828
|
+
f2.warn("Please make sure you have the adapter-static installed: https://kit.svelte.dev/docs/adapter-static");
|
|
93829
|
+
f2.warn("Please make sure you have the pages: 'dist' and assets: 'dest', in your svelte.config.js adaptater");
|
|
93830
|
+
const doContinue = await se({ message: "Do you want to continue?" });
|
|
93831
|
+
if (!doContinue) {
|
|
93832
|
+
f2.error("Aborted");
|
|
93833
|
+
program.error("");
|
|
93834
|
+
}
|
|
93835
|
+
return "build";
|
|
93836
|
+
}
|
|
93837
|
+
return "build";
|
|
93838
|
+
}
|
|
93773
93839
|
async function findMainFile() {
|
|
93774
93840
|
const mainRegex = /(main|index)\.(ts|tsx|js|jsx)$/;
|
|
93775
93841
|
let mainFile = "";
|
|
@@ -95419,10 +95485,14 @@ async function step4(userId, snag, apikey, appId) {
|
|
|
95419
95485
|
let coreVersion = pack.dependencies["@capacitor/core"] || pack.devDependencies["@capacitor/core"];
|
|
95420
95486
|
coreVersion = coreVersion?.replace("^", "").replace("~", "");
|
|
95421
95487
|
if (!coreVersion) {
|
|
95422
|
-
s.stop(
|
|
95488
|
+
s.stop("Error");
|
|
95489
|
+
f2.warn(`Cannot find @capacitor/core in package.json, please run \`capgo init\` in a capacitor project`);
|
|
95490
|
+
$e(`Bye \u{1F44B}`);
|
|
95423
95491
|
import_node_process16.default.exit();
|
|
95424
95492
|
} else if (import_semver.default.lt(coreVersion, "5.0.0")) {
|
|
95425
|
-
s.stop(
|
|
95493
|
+
s.stop("Error");
|
|
95494
|
+
f2.warn(`@capacitor/core version is ${coreVersion}, please update to Capacitor v5 first: ${urlMigrateV5}`);
|
|
95495
|
+
$e(`Bye \u{1F44B}`);
|
|
95426
95496
|
import_node_process16.default.exit();
|
|
95427
95497
|
} else if (import_semver.default.lt(coreVersion, "6.0.0")) {
|
|
95428
95498
|
s.stop(`@capacitor/core version is ${coreVersion}, please update to Capacitor v6: ${urlMigrateV6} to access the best features of Capgo`);
|
|
@@ -95430,7 +95500,9 @@ async function step4(userId, snag, apikey, appId) {
|
|
|
95430
95500
|
}
|
|
95431
95501
|
const pm = findPackageManagerType();
|
|
95432
95502
|
if (pm === "unknown") {
|
|
95433
|
-
s.stop(
|
|
95503
|
+
s.stop("Error");
|
|
95504
|
+
f2.warn(`Cannot reconize package manager, please run \`capgo init\` in a capacitor project with npm, pnpm or yarn`);
|
|
95505
|
+
$e(`Bye \u{1F44B}`);
|
|
95434
95506
|
import_node_process16.default.exit();
|
|
95435
95507
|
}
|
|
95436
95508
|
const installCmd = pm === "yarn" ? "add" : "install";
|
|
@@ -95451,9 +95523,16 @@ async function step5(userId, snag, apikey, appId) {
|
|
|
95451
95523
|
if (doAddCode) {
|
|
95452
95524
|
const s = de();
|
|
95453
95525
|
s.start(`Adding @capacitor-updater to your main file`);
|
|
95454
|
-
const
|
|
95526
|
+
const projectType = await findProjectType();
|
|
95527
|
+
let mainFilePath;
|
|
95528
|
+
if (projectType === "unknown")
|
|
95529
|
+
mainFilePath = await findMainFile();
|
|
95530
|
+
else
|
|
95531
|
+
mainFilePath = await findMainFileForProjectType(projectType);
|
|
95455
95532
|
if (!mainFilePath) {
|
|
95456
|
-
s.stop("
|
|
95533
|
+
s.stop("Error");
|
|
95534
|
+
f2.warn("Cannot find main file, You need to add @capgo/capacitor-updater manually");
|
|
95535
|
+
$e(`Bye \u{1F44B}`);
|
|
95457
95536
|
import_node_process16.default.exit();
|
|
95458
95537
|
}
|
|
95459
95538
|
const mainFile = (0, import_node_fs11.readFileSync)(mainFilePath);
|
|
@@ -95461,7 +95540,9 @@ async function step5(userId, snag, apikey, appId) {
|
|
|
95461
95540
|
const matches = mainFileContent.match(regexImport);
|
|
95462
95541
|
const last = matches?.pop();
|
|
95463
95542
|
if (!last) {
|
|
95464
|
-
s.stop(
|
|
95543
|
+
s.stop("Error");
|
|
95544
|
+
f2.warn(`Cannot find import line in main file, use manual installation: https://capgo.app/docs/plugin/installation/`);
|
|
95545
|
+
$e(`Bye \u{1F44B}`);
|
|
95465
95546
|
import_node_process16.default.exit();
|
|
95466
95547
|
}
|
|
95467
95548
|
if (mainFileContent.includes(codeInject)) {
|
|
@@ -95491,9 +95572,11 @@ async function step6(userId, snag, apikey, appId) {
|
|
|
95491
95572
|
if (doEncrypt) {
|
|
95492
95573
|
const s = de();
|
|
95493
95574
|
s.start(`Running: npx @capgo/cli@latest key create`);
|
|
95494
|
-
const keyRes = await createKey({}, false);
|
|
95575
|
+
const keyRes = await createKey({ force: true }, false);
|
|
95495
95576
|
if (!keyRes) {
|
|
95496
|
-
s.stop(
|
|
95577
|
+
s.stop("Error");
|
|
95578
|
+
f2.warn(`Cannot create key \u274C`);
|
|
95579
|
+
$e(`Bye \u{1F44B}`);
|
|
95497
95580
|
import_node_process16.default.exit(1);
|
|
95498
95581
|
} else {
|
|
95499
95582
|
s.stop(`key created \u{1F511}`);
|
|
@@ -95507,13 +95590,17 @@ async function step7(userId, snag, apikey, appId) {
|
|
|
95507
95590
|
await cancelCommand2(doBuild, userId, snag);
|
|
95508
95591
|
if (doBuild) {
|
|
95509
95592
|
const s = de();
|
|
95510
|
-
|
|
95593
|
+
const projectType = await findProjectType();
|
|
95594
|
+
const buildCommand = await findBuildCommandForProjectType(projectType);
|
|
95595
|
+
s.start(`Running: npm run ${buildCommand} && npx cap sync`);
|
|
95511
95596
|
const pack = JSON.parse((0, import_node_fs11.readFileSync)("package.json").toString());
|
|
95512
|
-
if (!pack.scripts
|
|
95513
|
-
s.stop(
|
|
95597
|
+
if (!pack.scripts[buildCommand]) {
|
|
95598
|
+
s.stop("Error");
|
|
95599
|
+
f2.warn(`Cannot find ${buildCommand} script in package.json, please add it and run \`capgo init\` again`);
|
|
95600
|
+
$e(`Bye \u{1F44B}`);
|
|
95514
95601
|
import_node_process16.default.exit();
|
|
95515
95602
|
}
|
|
95516
|
-
(0, import_node_child_process6.execSync)(`npm run
|
|
95603
|
+
(0, import_node_child_process6.execSync)(`npm run ${buildCommand} && npx cap sync`, execOption);
|
|
95517
95604
|
s.stop(`Build & Sync Done \u2705`);
|
|
95518
95605
|
} else {
|
|
95519
95606
|
f2.info(`Build yourself with command: npm run build && npx cap sync`);
|
|
@@ -95531,7 +95618,9 @@ async function step8(userId, snag, apikey, appId) {
|
|
|
95531
95618
|
apikey
|
|
95532
95619
|
}, false);
|
|
95533
95620
|
if (!uploadRes) {
|
|
95534
|
-
s.stop(
|
|
95621
|
+
s.stop("Error");
|
|
95622
|
+
f2.warn(`Upload failed \u274C`);
|
|
95623
|
+
$e(`Bye \u{1F44B}`);
|
|
95535
95624
|
import_node_process16.default.exit();
|
|
95536
95625
|
} else {
|
|
95537
95626
|
s.stop(`Upload Done \u2705`);
|
|
@@ -95552,8 +95641,10 @@ async function step9(userId, snag) {
|
|
|
95552
95641
|
{ value: "android", label: "Android" }
|
|
95553
95642
|
]
|
|
95554
95643
|
});
|
|
95555
|
-
if (eD(plaformType))
|
|
95644
|
+
if (eD(plaformType)) {
|
|
95645
|
+
$e(`Bye \u{1F44B}`);
|
|
95556
95646
|
import_node_process16.default.exit();
|
|
95647
|
+
}
|
|
95557
95648
|
const platform2 = plaformType;
|
|
95558
95649
|
const s = de();
|
|
95559
95650
|
s.start(`Running: npx cap run ${platform2}`);
|
package/package.json
CHANGED
package/src/init.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { login } from './login'
|
|
|
16
16
|
import { addApp } from './app/add'
|
|
17
17
|
import { checkLatest } from './api/update'
|
|
18
18
|
import type { Options } from './api/app'
|
|
19
|
-
import { convertAppName, createSupabaseClient, findMainFile, findSavedKey, getConfig, useLogSnag, verifyUser } from './utils'
|
|
19
|
+
import { convertAppName, createSupabaseClient, findBuildCommandForProjectType, findMainFile, findMainFileForProjectType, findProjectType, findSavedKey, getConfig, useLogSnag, verifyUser } from './utils'
|
|
20
20
|
|
|
21
21
|
interface SuperOptions extends Options {
|
|
22
22
|
local: boolean
|
|
@@ -92,11 +92,15 @@ async function step4(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
92
92
|
let coreVersion = pack.dependencies['@capacitor/core'] || pack.devDependencies['@capacitor/core']
|
|
93
93
|
coreVersion = coreVersion?.replace('^', '').replace('~', '')
|
|
94
94
|
if (!coreVersion) {
|
|
95
|
-
s.stop(
|
|
95
|
+
s.stop('Error')
|
|
96
|
+
p.log.warn(`Cannot find @capacitor/core in package.json, please run \`capgo init\` in a capacitor project`)
|
|
97
|
+
p.outro(`Bye 👋`)
|
|
96
98
|
process.exit()
|
|
97
99
|
}
|
|
98
100
|
else if (semver.lt(coreVersion, '5.0.0')) {
|
|
99
|
-
s.stop(
|
|
101
|
+
s.stop('Error')
|
|
102
|
+
p.log.warn(`@capacitor/core version is ${coreVersion}, please update to Capacitor v5 first: ${urlMigrateV5}`)
|
|
103
|
+
p.outro(`Bye 👋`)
|
|
100
104
|
process.exit()
|
|
101
105
|
}
|
|
102
106
|
else if (semver.lt(coreVersion, '6.0.0')) {
|
|
@@ -105,7 +109,9 @@ async function step4(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
105
109
|
}
|
|
106
110
|
const pm = findPackageManagerType()
|
|
107
111
|
if (pm === 'unknown') {
|
|
108
|
-
s.stop(
|
|
112
|
+
s.stop('Error')
|
|
113
|
+
p.log.warn(`Cannot reconize package manager, please run \`capgo init\` in a capacitor project with npm, pnpm or yarn`)
|
|
114
|
+
p.outro(`Bye 👋`)
|
|
109
115
|
process.exit()
|
|
110
116
|
}
|
|
111
117
|
// // use pm to install capgo
|
|
@@ -132,9 +138,17 @@ async function step5(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
132
138
|
if (doAddCode) {
|
|
133
139
|
const s = p.spinner()
|
|
134
140
|
s.start(`Adding @capacitor-updater to your main file`)
|
|
135
|
-
const
|
|
141
|
+
const projectType = await findProjectType()
|
|
142
|
+
let mainFilePath
|
|
143
|
+
if (projectType === 'unknown')
|
|
144
|
+
mainFilePath = await findMainFile()
|
|
145
|
+
else
|
|
146
|
+
mainFilePath = await findMainFileForProjectType(projectType)
|
|
147
|
+
|
|
136
148
|
if (!mainFilePath) {
|
|
137
|
-
s.stop('
|
|
149
|
+
s.stop('Error')
|
|
150
|
+
p.log.warn('Cannot find main file, You need to add @capgo/capacitor-updater manually')
|
|
151
|
+
p.outro(`Bye 👋`)
|
|
138
152
|
process.exit()
|
|
139
153
|
}
|
|
140
154
|
// open main file and inject codeInject
|
|
@@ -144,7 +158,9 @@ async function step5(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
144
158
|
const matches = mainFileContent.match(regexImport)
|
|
145
159
|
const last = matches?.pop()
|
|
146
160
|
if (!last) {
|
|
147
|
-
s.stop(
|
|
161
|
+
s.stop('Error')
|
|
162
|
+
p.log.warn(`Cannot find import line in main file, use manual installation: https://capgo.app/docs/plugin/installation/`)
|
|
163
|
+
p.outro(`Bye 👋`)
|
|
148
164
|
process.exit()
|
|
149
165
|
}
|
|
150
166
|
|
|
@@ -169,9 +185,11 @@ async function step6(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
169
185
|
if (doEncrypt) {
|
|
170
186
|
const s = p.spinner()
|
|
171
187
|
s.start(`Running: npx @capgo/cli@latest key create`)
|
|
172
|
-
const keyRes = await createKey({}, false)
|
|
188
|
+
const keyRes = await createKey({ force: true }, false)
|
|
173
189
|
if (!keyRes) {
|
|
174
|
-
s.stop(
|
|
190
|
+
s.stop('Error')
|
|
191
|
+
p.log.warn(`Cannot create key ❌`)
|
|
192
|
+
p.outro(`Bye 👋`)
|
|
175
193
|
process.exit(1)
|
|
176
194
|
}
|
|
177
195
|
else {
|
|
@@ -187,14 +205,18 @@ async function step7(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
187
205
|
await cancelCommand(doBuild, userId, snag)
|
|
188
206
|
if (doBuild) {
|
|
189
207
|
const s = p.spinner()
|
|
190
|
-
|
|
208
|
+
const projectType = await findProjectType()
|
|
209
|
+
const buildCommand = await findBuildCommandForProjectType(projectType)
|
|
210
|
+
s.start(`Running: npm run ${buildCommand} && npx cap sync`)
|
|
191
211
|
const pack = JSON.parse(readFileSync('package.json').toString())
|
|
192
212
|
// check in script build exist
|
|
193
|
-
if (!pack.scripts
|
|
194
|
-
s.stop(
|
|
213
|
+
if (!pack.scripts[buildCommand]) {
|
|
214
|
+
s.stop('Error')
|
|
215
|
+
p.log.warn(`Cannot find ${buildCommand} script in package.json, please add it and run \`capgo init\` again`)
|
|
216
|
+
p.outro(`Bye 👋`)
|
|
195
217
|
process.exit()
|
|
196
218
|
}
|
|
197
|
-
execSync(`npm run
|
|
219
|
+
execSync(`npm run ${buildCommand} && npx cap sync`, execOption as ExecSyncOptions)
|
|
198
220
|
s.stop(`Build & Sync Done ✅`)
|
|
199
221
|
}
|
|
200
222
|
else {
|
|
@@ -214,7 +236,9 @@ async function step8(userId: string, snag: LogSnag, apikey: string, appId: strin
|
|
|
214
236
|
apikey,
|
|
215
237
|
}, false)
|
|
216
238
|
if (!uploadRes) {
|
|
217
|
-
s.stop(
|
|
239
|
+
s.stop('Error')
|
|
240
|
+
p.log.warn(`Upload failed ❌`)
|
|
241
|
+
p.outro(`Bye 👋`)
|
|
218
242
|
process.exit()
|
|
219
243
|
}
|
|
220
244
|
else {
|
|
@@ -238,8 +262,10 @@ async function step9(userId: string, snag: LogSnag) {
|
|
|
238
262
|
{ value: 'android', label: 'Android' },
|
|
239
263
|
],
|
|
240
264
|
})
|
|
241
|
-
if (p.isCancel(plaformType))
|
|
265
|
+
if (p.isCancel(plaformType)) {
|
|
266
|
+
p.outro(`Bye 👋`)
|
|
242
267
|
process.exit()
|
|
268
|
+
}
|
|
243
269
|
|
|
244
270
|
const platform = plaformType as 'ios' | 'android'
|
|
245
271
|
const s = p.spinner()
|
package/src/utils.ts
CHANGED
|
@@ -324,6 +324,91 @@ async function* getFiles(dir: string): AsyncGenerator<string> {
|
|
|
324
324
|
yield res
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
|
|
328
|
+
export async function findProjectType() {
|
|
329
|
+
// for nuxtjs check if nuxt.config.js exists
|
|
330
|
+
// for nextjs check if next.config.js exists
|
|
331
|
+
// for angular check if angular.json exists
|
|
332
|
+
// for sveltekit check if svelte.config.js exists
|
|
333
|
+
const pwd = process.cwd()
|
|
334
|
+
for await (const f of getFiles(pwd)) {
|
|
335
|
+
// find number of folder in path after pwd
|
|
336
|
+
if (f.includes('angular.json')) {
|
|
337
|
+
p.log.info('Found angular project')
|
|
338
|
+
return 'angular'
|
|
339
|
+
}
|
|
340
|
+
if (f.includes('nuxt.config.js')) {
|
|
341
|
+
p.log.info('Found nuxtjs project')
|
|
342
|
+
return 'nuxtjs'
|
|
343
|
+
}
|
|
344
|
+
if (f.includes('next.config.js')) {
|
|
345
|
+
p.log.info('Found nextjs project')
|
|
346
|
+
return 'nextjs'
|
|
347
|
+
}
|
|
348
|
+
if (f.includes('svelte.config.js')) {
|
|
349
|
+
p.log.info('Found sveltekit project')
|
|
350
|
+
return 'sveltekit'
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return 'unknown'
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export async function findMainFileForProjectType(projectType: string) {
|
|
357
|
+
if (projectType === 'angular')
|
|
358
|
+
return 'src/main.ts'
|
|
359
|
+
|
|
360
|
+
if (projectType === 'nuxtjs')
|
|
361
|
+
return 'src/main.ts'
|
|
362
|
+
|
|
363
|
+
if (projectType === 'nextjs')
|
|
364
|
+
return 'pages/_app.tsx'
|
|
365
|
+
|
|
366
|
+
if (projectType === 'sveltekit')
|
|
367
|
+
return 'src/main.ts'
|
|
368
|
+
|
|
369
|
+
return null
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// create a function to find the right command to build the project in static mode depending on the project type
|
|
373
|
+
|
|
374
|
+
export async function findBuildCommandForProjectType(projectType: string) {
|
|
375
|
+
if (projectType === 'angular') {
|
|
376
|
+
p.log.info('Angular project detected')
|
|
377
|
+
return 'build'
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (projectType === 'nuxtjs') {
|
|
381
|
+
p.log.info('Nuxtjs project detected')
|
|
382
|
+
return 'generate'
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (projectType === 'nextjs') {
|
|
386
|
+
p.log.info('Nextjs project detected')
|
|
387
|
+
p.log.warn('Please make sure you have configured static export in your next.config.js: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports')
|
|
388
|
+
p.log.warn('Please make sure you have the output: \'export\' and distDir: \'dist\' in your next.config.js')
|
|
389
|
+
const doContinue = await p.confirm({ message: 'Do you want to continue?' })
|
|
390
|
+
if (!doContinue) {
|
|
391
|
+
p.log.error('Aborted')
|
|
392
|
+
program.error('')
|
|
393
|
+
}
|
|
394
|
+
return 'build'
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (projectType === 'sveltekit') {
|
|
398
|
+
p.log.info('Sveltekit project detected')
|
|
399
|
+
p.log.warn('Please make sure you have the adapter-static installed: https://kit.svelte.dev/docs/adapter-static')
|
|
400
|
+
p.log.warn('Please make sure you have the pages: \'dist\' and assets: \'dest\', in your svelte.config.js adaptater')
|
|
401
|
+
const doContinue = await p.confirm({ message: 'Do you want to continue?' })
|
|
402
|
+
if (!doContinue) {
|
|
403
|
+
p.log.error('Aborted')
|
|
404
|
+
program.error('')
|
|
405
|
+
}
|
|
406
|
+
return 'build'
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return 'build'
|
|
410
|
+
}
|
|
411
|
+
|
|
327
412
|
export async function findMainFile() {
|
|
328
413
|
const mainRegex = /(main|index)\.(ts|tsx|js|jsx)$/
|
|
329
414
|
// search for main.ts or main.js in local dir and subdirs
|