Skip to content

Commit 17fbabb

Browse files
authored
feat(cli): add inline option to copy command (#5901)
* feat(cli): add inline option to copy command * chore: fix update default passed to copy * chore: make inlines optional with false default
1 parent d84352d commit 17fbabb

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

cli/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,17 @@ export function runProgram(config: Config): void {
122122
program
123123
.command('copy [platform]')
124124
.description('copies the web app build into the native app')
125+
.option(
126+
'--inline',
127+
'Optional: if true, all source maps will be inlined for easier debugging on mobile devices',
128+
false,
129+
)
125130
.action(
126131
wrapAction(
127-
telemetryAction(config, async platform => {
132+
telemetryAction(config, async (platform, { inline }) => {
128133
checkExternalConfig(config.app);
129134
const { copyCommand } = await import('./tasks/copy');
130-
await copyCommand(config, platform);
135+
await copyCommand(config, platform, inline);
131136
}),
132137
),
133138
);

cli/src/tasks/copy.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ import { getPlugins } from '../plugin';
2323
import { allSerial } from '../util/promise';
2424
import { copyWeb } from '../web/copy';
2525

26+
import { inlineSourceMaps } from './sourcemaps';
27+
2628
export async function copyCommand(
2729
config: Config,
2830
selectedPlatformName: string,
31+
inline = false,
2932
): Promise<void> {
3033
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
3134
const platformDir = resolvePlatform(config, selectedPlatformName);
@@ -43,7 +46,7 @@ export async function copyCommand(
4346
const platforms = await selectPlatforms(config, selectedPlatformName);
4447
try {
4548
await allSerial(
46-
platforms.map(platformName => () => copy(config, platformName)),
49+
platforms.map(platformName => () => copy(config, platformName, inline)),
4750
);
4851
} catch (e) {
4952
if (isFatal(e)) {
@@ -58,6 +61,7 @@ export async function copyCommand(
5861
export async function copy(
5962
config: Config,
6063
platformName: string,
64+
inline = false,
6165
): Promise<void> {
6266
await runTask(c.success(c.strong(`copy ${platformName}`)), async () => {
6367
const result = await checkWebDir(config);
@@ -134,6 +138,9 @@ export async function copy(
134138
} else {
135139
throw `Platform ${platformName} is not valid.`;
136140
}
141+
if (inline) {
142+
await inlineSourceMaps(config, platformName);
143+
}
137144
});
138145

139146
await runPlatformHook(

cli/src/tasks/sync.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { logger } from '../log';
1212
import { allSerial } from '../util/promise';
1313

1414
import { copy, copyCommand } from './copy';
15-
import { inlineSourceMaps } from './sourcemaps';
1615
import { update, updateChecks, updateCommand } from './update';
1716

1817
/**
@@ -22,11 +21,11 @@ export async function syncCommand(
2221
config: Config,
2322
selectedPlatformName: string,
2423
deployment: boolean,
25-
inline: boolean,
24+
inline = false,
2625
): Promise<void> {
2726
if (selectedPlatformName && !(await isValidPlatform(selectedPlatformName))) {
2827
try {
29-
await copyCommand(config, selectedPlatformName);
28+
await copyCommand(config, selectedPlatformName, inline);
3029
} catch (e) {
3130
logger.error(e.stack ?? e);
3231
}
@@ -62,7 +61,7 @@ export async function sync(
6261
config: Config,
6362
platformName: string,
6463
deployment: boolean,
65-
inline: boolean,
64+
inline = false,
6665
): Promise<void> {
6766
await runPlatformHook(
6867
config,
@@ -72,10 +71,7 @@ export async function sync(
7271
);
7372

7473
try {
75-
await copy(config, platformName);
76-
if (inline) {
77-
await inlineSourceMaps(config, platformName);
78-
}
74+
await copy(config, platformName, inline);
7975
} catch (e) {
8076
logger.error(e.stack ?? e);
8177
}

0 commit comments

Comments
 (0)