Skip to content

Commit 59a70c7

Browse files
committed
feat: add server command flag in launch
1 parent 6e4ddb7 commit 59a70c7

File tree

7 files changed

+33
-6
lines changed

7 files changed

+33
-6
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ With Launch CLI, you can interact with the Contentstack Launch platform using th
66

77
<!-- toc -->
88
* [Launch CLI plugin](#launch-cli-plugin)
9-
* [Usage](#usage)
109
* [Installation steps](#installation-steps)
1110
* [Commands](#commands)
1211
<!-- tocstop -->
@@ -38,4 +37,4 @@ $ csdx launch:functions
3837
Run cloud functions locally
3938
```
4039

41-
<!-- commandsstop -->
40+
<!-- commandsstop -->

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-launch",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"description": "Launch related operations",
55
"author": "Contentstack CLI",
66
"bin": {

src/adapters/file-upload.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default class FileUpload extends BaseClass {
6262
* @memberof FileUpload
6363
*/
6464
async createNewProject(): Promise<void> {
65-
const { framework, projectName, buildCommand, outputDirectory, environmentName } = this.config;
65+
const { framework, projectName, buildCommand, outputDirectory, environmentName, serverCommand } = this.config;
6666
await this.apolloClient
6767
.mutate({
6868
mutation: importProjectMutation,
@@ -77,6 +77,7 @@ export default class FileUpload extends BaseClass {
7777
name: environmentName || 'Default',
7878
environmentVariables: map(this.envVariables, ({ key, value }) => ({ key, value })),
7979
buildCommand: buildCommand === undefined || buildCommand === null ? 'npm run build' : buildCommand,
80+
serverCommand: serverCommand === undefined || serverCommand === null ? 'npm run start' : serverCommand,
8081
},
8182
},
8283
skipGitData: true,
@@ -113,6 +114,7 @@ export default class FileUpload extends BaseClass {
113114
'out-dir': outputDirectory,
114115
'variable-type': variableType,
115116
'env-variables': envVariables,
117+
'server-command': serverCommand,
116118
alias,
117119
} = this.config.flags;
118120
const { token, apiKey } = configHandler.get(`tokens.${alias}`) ?? {};
@@ -171,6 +173,15 @@ export default class FileUpload extends BaseClass {
171173
message: 'Output Directory',
172174
default: (this.config.outputDirectories as Record<string, string>)[this.config?.framework || 'OTHER'],
173175
}));
176+
if (this.config.framework && this.config.supportedFrameworksForServerCommands.includes(this.config.framework)) {
177+
this.config.serverCommand =
178+
serverCommand ||
179+
(await cliux.inquire({
180+
type: 'input',
181+
name: 'serverCommand',
182+
message: 'Server Command',
183+
}));
184+
}
174185
this.config.variableType = variableType as unknown as string;
175186
this.config.envVariables = envVariables;
176187
await this.handleEnvImportFlow();

src/adapters/github.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default class GitHub extends BaseClass {
6464
outputDirectory,
6565
environmentName,
6666
provider: gitProvider,
67+
serverCommand,
6768
} = this.config;
6869
const username = split(repository?.fullName, '/')[0];
6970

@@ -87,6 +88,7 @@ export default class GitHub extends BaseClass {
8788
name: environmentName || 'Default',
8889
environmentVariables: map(this.envVariables, ({ key, value }) => ({ key, value })),
8990
buildCommand: buildCommand === undefined || buildCommand === null ? 'npm run build' : buildCommand,
91+
serverCommand: serverCommand === undefined || serverCommand === null ? 'npm run start' : serverCommand,
9092
},
9193
},
9294
},
@@ -122,6 +124,7 @@ export default class GitHub extends BaseClass {
122124
'out-dir': outputDirectory,
123125
'variable-type': variableType,
124126
'env-variables': envVariables,
127+
'server-command': serverCommand,
125128
alias,
126129
} = this.config.flags;
127130
const { token, apiKey } = configHandler.get(`tokens.${alias}`) ?? {};
@@ -182,6 +185,15 @@ export default class GitHub extends BaseClass {
182185
message: 'Output Directory',
183186
default: (this.config.outputDirectories as Record<string, string>)[this.config?.framework || 'OTHER'],
184187
}));
188+
if (this.config.framework && this.config.supportedFrameworksForServerCommands.includes(this.config.framework)) {
189+
this.config.serverCommand =
190+
serverCommand ||
191+
(await ux.inquire({
192+
type: 'input',
193+
name: 'serverCommand',
194+
message: 'Server Command',
195+
}));
196+
}
185197
this.config.variableType = variableType as unknown as string;
186198
this.config.envVariables = envVariables;
187199
await this.handleEnvImportFlow();

src/commands/launch/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class Launch extends BaseCommand<typeof Launch> {
1919
'<%= config.bin %> <%= command.id %> --data-dir <path/of/current/working/dir> --type <options: GitHub|FileUpload>',
2020
'<%= config.bin %> <%= command.id %> --config <path/to/launch/config/file> --type <options: GitHub|FileUpload>',
2121
'<%= config.bin %> <%= command.id %> --config <path/to/launch/config/file> --type <options: GitHub|FileUpload> --name=<value> --environment=<value> --branch=<value> --build-command=<value> --framework=<option> --org=<value> --out-dir=<value>',
22+
'<%= config.bin %> <%= command.id %> --config <path/to/launch/config/file> --type <options: GitHub|FileUpload> --name=<value> --environment=<value> --branch=<value> --build-command=<value> --framework=<option> --org=<value> --out-dir=<value> --server-command=<value>',
2223
'<%= config.bin %> <%= command.id %> --config <path/to/launch/config/file> --type <options: GitHub|FileUpload> --name=<value> --environment=<value> --branch=<value> --build-command=<value> --framework=<option> --org=<value> --out-dir=<value> --variable-type="Import variables from a stack" --alias=<value>',
2324
'<%= config.bin %> <%= command.id %> --config <path/to/launch/config/file> --type <options: GitHub|FileUpload> --name=<value> --environment=<value> --branch=<value> --build-command=<value> --framework=<option> --org=<value> --out-dir=<value> --variable-type="Manually add custom variables to the list" --env-variables="APP_ENV:prod, TEST_ENV:testVal"',
2425
];
@@ -52,6 +53,9 @@ export default class Launch extends BaseCommand<typeof Launch> {
5253
'out-dir': Flags.string({
5354
description: '[optional] Output Directory.',
5455
}),
56+
'server-command': Flags.string({
57+
description: '[optional] Server Command.',
58+
}),
5559
'variable-type': Flags.string({
5660
options: [...config.variablePreparationTypeOptions],
5761
description: '[optional] Provide a variable type. <options: Import variables from a stack|Manually add custom variables to the list|Import variables from the local env file>',

src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const config = {
4040
'Import variables from the local env file',
4141
],
4242
variableType: '',
43+
supportedFrameworksForServerCommands: ['ANGULAR', 'OTHER', 'REMIX']
4344
};
4445

4546
export default config;

0 commit comments

Comments
 (0)