Skip to content

Commit 749d836

Browse files
Add --skipValidation for jss setup command
1 parent 16ee0ce commit 749d836

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

packages/sitecore-jss-cli/src/scripts/setup.ts

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export const builder = {
4343
type: 'string',
4444
describe: 'The file path to output the config to. Defaults to the app\'s scjssconfig.json',
4545
},
46+
skipValidation: {
47+
requiresArg: false,
48+
type: 'boolean',
49+
describe: 'Skip validation of command arguments (e.g. for CI)',
50+
},
4651
};
4752

4853
export async function handler(argv: any) {

packages/sitecore-jss-dev-tools/src/resolve-scjssconfig.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface JssConfiguration {
66
instancePath?: string;
77
apiKey?: string;
88
layoutServiceHost?: string;
9+
skipValidation?: boolean;
910
}
1011

1112
export interface ScJssConfig {

packages/sitecore-jss-dev-tools/src/setup/setup.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function getInteractiveData(
5353
}
5454

5555
export function setup(interactive: boolean, outputFile?: string, initialData?: JssConfiguration, configName = 'sitecore') {
56+
const getValidation = (regexp: RegExp) => initialData?.skipValidation ? undefined : regexp;
57+
5658
let config: ScJssConfig = {
5759
sitecore: {
5860
instancePath: '',
@@ -100,7 +102,7 @@ export function setup(interactive: boolean, outputFile?: string, initialData?: J
100102
'instancePath',
101103
'Path to the Sitecore folder',
102104
'(e.g. c:\\inetpub\\wwwroot\\my.siteco.re)',
103-
/[A-z]/,
105+
getValidation(/[A-z]/),
104106
'Invalid input.',
105107
true
106108
);
@@ -143,7 +145,7 @@ export function setup(interactive: boolean, outputFile?: string, initialData?: J
143145
'host',
144146
'Sitecore hostname',
145147
'(e.g. http://myapp.local.siteco.re; see /sitecore/config; ensure added to hosts)',
146-
/^https?:\/\/(.*)/,
148+
getValidation(/^https?:\/\/(.*)/),
147149
'Invalid input. Must start with http(s)'
148150
);
149151
}
@@ -155,7 +157,7 @@ export function setup(interactive: boolean, outputFile?: string, initialData?: J
155157
'host',
156158
'Sitecore import service URL',
157159
'(usually same as hostname)',
158-
/^https?:\/\/(.*)/,
160+
getValidation(/^https?:\/\/(.*)/),
159161
'Invalid input. Must start with http(s)'
160162
);
161163
}
@@ -167,7 +169,7 @@ export function setup(interactive: boolean, outputFile?: string, initialData?: J
167169
'apiKey',
168170
'Sitecore API Key',
169171
'(ID of API key item)',
170-
/^{?[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}}?$/i,
172+
getValidation(/^{?[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}}?$/i),
171173
'Invalid API Key. Should be a GUID / Sitecore Item ID.'
172174
);
173175

@@ -178,7 +180,7 @@ export function setup(interactive: boolean, outputFile?: string, initialData?: J
178180
'deploySecret',
179181
'Please enter your deployment secret',
180182
'(32+ random chars; or press enter to generate one)',
181-
/^(.{32,}|)$/,
183+
getValidation(/^(.{32,}|)$/),
182184
'Invalid secret. Should be blank or at least 32 random characters.',
183185
true
184186
);

0 commit comments

Comments
 (0)