contensis-cli 1.1.2-beta.2 → 1.1.2-beta.3
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/dist/commands/dev.js +11 -4
- package/dist/commands/dev.js.map +2 -2
- package/dist/commands/get.js +1 -0
- package/dist/commands/get.js.map +2 -2
- package/dist/factories/RequestHandlerFactory.js +22 -12
- package/dist/factories/RequestHandlerFactory.js.map +2 -2
- package/dist/localisation/en-GB.js +2 -0
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +112 -90
- package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +2 -2
- package/dist/providers/GitHubCliModuleProvider.js +13 -5
- package/dist/providers/GitHubCliModuleProvider.js.map +2 -2
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisDevService.js +30 -5
- package/dist/services/ContensisDevService.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/dev.ts +14 -6
- package/src/commands/get.ts +1 -0
- package/src/factories/RequestHandlerFactory.ts +33 -16
- package/src/localisation/en-GB.ts +2 -0
- package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +128 -94
- package/src/providers/GitHubCliModuleProvider.ts +10 -6
- package/src/providers/file-provider.ts +1 -0
- package/src/services/ContensisDevService.ts +37 -6
- package/src/version.ts +1 -1
package/src/commands/dev.ts
CHANGED
|
@@ -49,20 +49,28 @@ Example call:
|
|
|
49
49
|
dev
|
|
50
50
|
.command('requests')
|
|
51
51
|
.description('launch request handler for local development')
|
|
52
|
-
.argument(
|
|
52
|
+
.argument(
|
|
53
|
+
'[block-id...]',
|
|
54
|
+
'id of block to develop locally and the local uri to pass requests for this block onto'
|
|
55
|
+
)
|
|
53
56
|
.option('--args <args...>', 'override or add additional args')
|
|
54
|
-
.
|
|
57
|
+
.option(
|
|
58
|
+
'--release <release>',
|
|
59
|
+
'launch a specific release version of the request handler'
|
|
60
|
+
)
|
|
61
|
+
.usage('[block-id] [local-uri]')
|
|
55
62
|
.addHelpText(
|
|
56
63
|
'after',
|
|
57
64
|
`
|
|
58
65
|
Example call:
|
|
59
|
-
> dev requests test-block-one
|
|
66
|
+
> dev requests test-block-one
|
|
67
|
+
> dev requests my-website http://localhost:8080\n`
|
|
60
68
|
)
|
|
61
|
-
.action(async (
|
|
69
|
+
.action(async (blockId: string[] = [], opts) => {
|
|
62
70
|
await devCommand(
|
|
63
|
-
['dev', 'requests',
|
|
71
|
+
['dev', 'requests', blockId.join(' ')],
|
|
64
72
|
opts
|
|
65
|
-
).ExecRequestHandler(
|
|
73
|
+
).ExecRequestHandler(blockId, opts?.args, opts.release);
|
|
66
74
|
});
|
|
67
75
|
|
|
68
76
|
return dev;
|
package/src/commands/get.ts
CHANGED
|
@@ -298,6 +298,7 @@ Example call:
|
|
|
298
298
|
Example call:
|
|
299
299
|
> get block contensis-website
|
|
300
300
|
> get block contensis-website develop latest
|
|
301
|
+
> get block contensis-website feature-branch 3
|
|
301
302
|
`
|
|
302
303
|
)
|
|
303
304
|
.action(async (blockId: string, branch: string, version: string, opts) => {
|
|
@@ -6,7 +6,7 @@ import { LogMessages } from '~/localisation/en-GB';
|
|
|
6
6
|
import GitHubCliModuleProvider from '~/providers/GitHubCliModuleProvider';
|
|
7
7
|
|
|
8
8
|
import ManifestProvider from '~/providers/ManifestProvider';
|
|
9
|
-
import { appRootDir, joinPath } from '~/providers/file-provider';
|
|
9
|
+
import { appRootDir, checkDir, joinPath } from '~/providers/file-provider';
|
|
10
10
|
import { isDebug } from '~/util/debug';
|
|
11
11
|
import { Logger } from '~/util/logger';
|
|
12
12
|
|
|
@@ -21,6 +21,7 @@ export class RequestHandlerFactory {
|
|
|
21
21
|
cmd = 'Zengenti.Contensis.RequestHandler.LocalDevelopment';
|
|
22
22
|
|
|
23
23
|
prerelease;
|
|
24
|
+
version; // pass in a specific release version to run
|
|
24
25
|
|
|
25
26
|
get exePath() {
|
|
26
27
|
return path.join(this.basePath, `${this.name}-${this.moduleInfo.version}`);
|
|
@@ -35,29 +36,31 @@ export class RequestHandlerFactory {
|
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
constructor(prerelease = false) {
|
|
39
|
+
constructor(version?: string, prerelease = false) {
|
|
39
40
|
this.prerelease = prerelease;
|
|
41
|
+
this.version = version;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
// Use the factory to create a request handler instance
|
|
43
45
|
// handling the download and updating of the external binary
|
|
44
46
|
async Create() {
|
|
45
|
-
const { moduleInfo } = this;
|
|
46
|
-
const
|
|
47
|
+
const { moduleInfo, version } = this;
|
|
48
|
+
const downloadImmediately =
|
|
49
|
+
!moduleInfo?.version || moduleInfo?.version === '*' || this.version;
|
|
47
50
|
|
|
48
|
-
if (
|
|
51
|
+
if (downloadImmediately) {
|
|
49
52
|
// Create cli-manifest.json
|
|
50
53
|
this.manifest.writeModule(this.name, this.moduleInfo);
|
|
51
54
|
|
|
52
55
|
// Download for first time use (await)
|
|
53
|
-
await this.CheckUpdate({ verbose: true });
|
|
56
|
+
await this.CheckUpdate({ verbose: true, version });
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
// Apply any downloaded/pending update so we launch that version
|
|
57
60
|
await this.ApplyUpdate();
|
|
58
61
|
|
|
59
62
|
// Fire an async update check and continue working in the background (do not await)
|
|
60
|
-
if (!
|
|
63
|
+
if (!downloadImmediately) this.CheckUpdate();
|
|
61
64
|
|
|
62
65
|
// Return a RequestHandler ready to invoke
|
|
63
66
|
return this.CreateInvoke(this);
|
|
@@ -121,13 +124,16 @@ export class RequestHandlerFactory {
|
|
|
121
124
|
};
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
async CheckUpdate({
|
|
127
|
+
async CheckUpdate({
|
|
128
|
+
verbose = false,
|
|
129
|
+
version,
|
|
130
|
+
}: { verbose?: boolean; version?: string } = {}) {
|
|
125
131
|
const { cmd, debug, log, manifest, messages, moduleInfo } = this;
|
|
126
132
|
|
|
127
133
|
const github = new GitHubCliModuleProvider(moduleInfo.github);
|
|
128
134
|
|
|
129
135
|
// Find latest version
|
|
130
|
-
const release = await github.FindLatestRelease();
|
|
136
|
+
const release = await github.FindLatestRelease(version);
|
|
131
137
|
|
|
132
138
|
if (verbose || debug)
|
|
133
139
|
if (release)
|
|
@@ -140,10 +146,14 @@ export class RequestHandlerFactory {
|
|
|
140
146
|
else
|
|
141
147
|
log.warning(messages.devrequests.install.notFound(moduleInfo.github));
|
|
142
148
|
|
|
149
|
+
const downloadSpecificRelease =
|
|
150
|
+
version && !checkDir('c') && release?.tag_name;
|
|
151
|
+
|
|
143
152
|
// Should we download an update?
|
|
144
153
|
if (
|
|
145
|
-
release?.tag_name &&
|
|
146
|
-
|
|
154
|
+
(release?.tag_name &&
|
|
155
|
+
![moduleInfo.version, moduleInfo.install].includes(release.tag_name)) ||
|
|
156
|
+
downloadSpecificRelease
|
|
147
157
|
) {
|
|
148
158
|
// Download platform-specific release asset
|
|
149
159
|
const downloadPath = path.join(
|
|
@@ -190,10 +200,16 @@ export class RequestHandlerFactory {
|
|
|
190
200
|
),
|
|
191
201
|
});
|
|
192
202
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
203
|
+
if (!version) {
|
|
204
|
+
// Update module info with downloaded release
|
|
205
|
+
this.moduleInfo.install = release.tag_name;
|
|
206
|
+
// Write module info update to manifest so it installs on next invoke
|
|
207
|
+
manifest.writeModule(this.name, this.moduleInfo);
|
|
208
|
+
} else {
|
|
209
|
+
// Set module version in memory so the request handler
|
|
210
|
+
// will be invoked with this version this time only
|
|
211
|
+
this.moduleInfo.version = release.tag_name;
|
|
212
|
+
}
|
|
197
213
|
}
|
|
198
214
|
}
|
|
199
215
|
}
|
|
@@ -226,4 +242,5 @@ export class RequestHandlerFactory {
|
|
|
226
242
|
}
|
|
227
243
|
}
|
|
228
244
|
|
|
229
|
-
export const createRequestHandler = () =>
|
|
245
|
+
export const createRequestHandler = (version?: string) =>
|
|
246
|
+
new RequestHandlerFactory(version).Create();
|
|
@@ -620,6 +620,8 @@ export const LogMessages = {
|
|
|
620
620
|
)}?`,
|
|
621
621
|
},
|
|
622
622
|
launch: () => `Launching request handler for local development`,
|
|
623
|
+
overrideBlock: () => `Which block will you be running?`,
|
|
624
|
+
overrideUri: () => `How to access your development site`,
|
|
623
625
|
spawn: () =>
|
|
624
626
|
`If you see a firewall popup requesting network access, it is safe to approve`,
|
|
625
627
|
exited: (code: number | null) =>
|
|
@@ -32,114 +32,148 @@ type RendererRuleJson = {
|
|
|
32
32
|
interface ISiteConfigYaml {
|
|
33
33
|
alias: string;
|
|
34
34
|
projectId: string;
|
|
35
|
-
accessToken: string;
|
|
35
|
+
accessToken: string; // needed?
|
|
36
36
|
clientId: string;
|
|
37
37
|
sharedSecret: string;
|
|
38
38
|
blocks: BlockJson[];
|
|
39
39
|
renderers: RendererJson[];
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
class RequestHandlerArgs {
|
|
43
|
+
private cli;
|
|
44
|
+
args?: string[];
|
|
45
|
+
siteConfig?: ISiteConfigYaml;
|
|
46
|
+
|
|
47
|
+
constructor(cli: ContensisCli) {
|
|
48
|
+
this.cli = cli;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Create = async () => {
|
|
52
|
+
this.siteConfig = await this.buildSiteConfig();
|
|
53
|
+
await this.cli.Login(this.cli.env.lastUserId, { silent: true }); // to hydrate the auth service
|
|
54
|
+
this.args = this.getArgs();
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
+
buildSiteConfig = async () => {
|
|
58
|
+
const { currentEnv, currentProject, env, log, messages } = this.cli;
|
|
59
|
+
const siteConfig: ISiteConfigYaml = {
|
|
60
|
+
alias: currentEnv,
|
|
61
|
+
projectId: currentProject,
|
|
62
|
+
accessToken: '',
|
|
63
|
+
clientId: '',
|
|
64
|
+
sharedSecret: '',
|
|
65
|
+
blocks: [],
|
|
66
|
+
renderers: [],
|
|
67
|
+
};
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
const getBlocks = async (contensis: ContensisMigrationService) => {
|
|
70
|
+
const [err, blocksRaw] = await contensis.blocks.GetBlocks();
|
|
71
|
+
if (err)
|
|
72
|
+
log.error(messages.blocks.noList(currentEnv, env.currentProject));
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
block
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
log.warning(
|
|
70
|
-
messages.blocks.noGet(
|
|
71
|
-
block.id,
|
|
72
|
-
'default',
|
|
73
|
-
'latest',
|
|
74
|
-
currentEnv,
|
|
75
|
-
env.currentProject
|
|
76
|
-
)
|
|
74
|
+
// const blocksRaw = await cli.PrintBlocks();
|
|
75
|
+
|
|
76
|
+
const blocks: BlockJson[] = [];
|
|
77
|
+
for (const block of blocksRaw || []) {
|
|
78
|
+
// Retrieve block version
|
|
79
|
+
const [err, versions] = await contensis.blocks.GetBlockVersions(
|
|
80
|
+
block.id,
|
|
81
|
+
'default',
|
|
82
|
+
'latest'
|
|
77
83
|
);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
if (err || versions?.length === 0)
|
|
85
|
+
log.warning(
|
|
86
|
+
messages.blocks.noGet(
|
|
87
|
+
block.id,
|
|
88
|
+
'default',
|
|
89
|
+
'latest',
|
|
90
|
+
currentEnv,
|
|
91
|
+
env.currentProject
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
if (versions?.[0]) {
|
|
95
|
+
const v = versions[0];
|
|
96
|
+
blocks.push({
|
|
97
|
+
id: v.id,
|
|
98
|
+
baseUri: v.previewUrl,
|
|
99
|
+
staticPaths: v.staticPaths,
|
|
100
|
+
endpoints: v.endpoints,
|
|
101
|
+
versionNo: v.version.versionNo,
|
|
102
|
+
branch: v.source.branch,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
88
105
|
}
|
|
106
|
+
return blocks;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const contensis = await this.cli.ConnectContensis();
|
|
110
|
+
if (contensis) {
|
|
111
|
+
const [blocks, renderers] = await Promise.all([
|
|
112
|
+
getBlocks(contensis),
|
|
113
|
+
contensis.renderers.GetRenderers(),
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
siteConfig.blocks = blocks;
|
|
117
|
+
siteConfig.renderers = renderers?.[1]?.map(r => ({
|
|
118
|
+
id: r.id,
|
|
119
|
+
name: r.name,
|
|
120
|
+
assignedContentTypes: r.assignedContentTypes,
|
|
121
|
+
rules: r.rules,
|
|
122
|
+
}));
|
|
89
123
|
}
|
|
90
|
-
return
|
|
124
|
+
return siteConfig;
|
|
91
125
|
};
|
|
92
126
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
siteConfig.blocks = blocks;
|
|
101
|
-
siteConfig.renderers = renderers?.[1]?.map(r => ({
|
|
102
|
-
id: r.id,
|
|
103
|
-
name: r.name,
|
|
104
|
-
assignedContentTypes: r.assignedContentTypes,
|
|
105
|
-
rules: r.rules,
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
return siteConfig;
|
|
109
|
-
};
|
|
127
|
+
getArgs = (overrideArgs: string[] = []) => {
|
|
128
|
+
const args = overrideArgs
|
|
129
|
+
? typeof overrideArgs?.[0] === 'string' &&
|
|
130
|
+
overrideArgs[0].includes(' ', 2)
|
|
131
|
+
? overrideArgs[0].split(' ')
|
|
132
|
+
: overrideArgs
|
|
133
|
+
: []; // args could be [ '-c .\\site_config.yaml' ] or [ '-c', '.\\site_config.yaml' ]
|
|
110
134
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!args.find(a => a === '--alias')) args.push('--alias', cli.currentEnv);
|
|
124
|
-
if (!args.find(a => a === '--project-api-id'))
|
|
125
|
-
args.push('--project-api-id', cli.currentProject);
|
|
126
|
-
if (!args.find(a => a === '--blocks-json'))
|
|
127
|
-
args.push('--blocks-json', JSON.stringify(siteConfig.blocks));
|
|
128
|
-
if (!args.find(a => a === '--renderers-json'))
|
|
129
|
-
args.push('--renderers-json', JSON.stringify(siteConfig.renderers));
|
|
130
|
-
|
|
131
|
-
await cli.Login(cli.env.lastUserId, { silent: true }); // to hydrate the auth service
|
|
132
|
-
const client = cli.auth?.clientDetails;
|
|
133
|
-
if (client) {
|
|
134
|
-
if (!args.find(a => a === '--client-id') && 'clientId' in client)
|
|
135
|
-
args.push('--client-id', client.clientId);
|
|
136
|
-
if (!args.find(a => a === '--client-secret') && 'clientSecret' in client)
|
|
137
|
-
args.push('--client-secret', client.clientSecret);
|
|
138
|
-
if (!args.find(a => a === '--username') && 'username' in client)
|
|
139
|
-
args.push('--username', client.username);
|
|
140
|
-
if (!args.find(a => a === '--password') && 'password' in client)
|
|
141
|
-
args.push('--password', client.password);
|
|
142
|
-
}
|
|
135
|
+
const { cli, siteConfig } = this;
|
|
136
|
+
if (siteConfig) {
|
|
137
|
+
// Add required args
|
|
138
|
+
if (!args.find(a => a === '--alias'))
|
|
139
|
+
args.push('--alias', cli.currentEnv);
|
|
140
|
+
if (!args.find(a => a === '--project-api-id'))
|
|
141
|
+
args.push('--project-api-id', cli.currentProject);
|
|
142
|
+
if (!args.find(a => a === '--blocks-json'))
|
|
143
|
+
args.push('--blocks-json', JSON.stringify(siteConfig.blocks));
|
|
144
|
+
if (!args.find(a => a === '--renderers-json'))
|
|
145
|
+
args.push('--renderers-json', JSON.stringify(siteConfig.renderers));
|
|
146
|
+
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
const client = cli.auth?.clientDetails;
|
|
149
|
+
if (client) {
|
|
150
|
+
if (!args.find(a => a === '--client-id') && 'clientId' in client)
|
|
151
|
+
args.push('--client-id', client.clientId);
|
|
152
|
+
if (!args.find(a => a === '--client-secret') && 'clientSecret' in client)
|
|
153
|
+
args.push('--client-secret', client.clientSecret);
|
|
154
|
+
if (!args.find(a => a === '--username') && 'username' in client)
|
|
155
|
+
args.push('--username', client.username);
|
|
156
|
+
if (!args.find(a => a === '--password') && 'password' in client)
|
|
157
|
+
args.push('--password', client.password);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return args;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
overrideBlock = (blockId: string, overrideUri: string) => {
|
|
164
|
+
if (blockId && blockId !== 'none') {
|
|
165
|
+
const blockIndex = this.siteConfig?.blocks.findIndex(
|
|
166
|
+
b => b.id.toLowerCase() === blockId.toLowerCase()
|
|
167
|
+
);
|
|
168
|
+
if (
|
|
169
|
+
typeof blockIndex === 'number' &&
|
|
170
|
+
!isNaN(blockIndex) &&
|
|
171
|
+
this.siteConfig?.blocks[blockIndex]
|
|
172
|
+
) {
|
|
173
|
+
this.siteConfig.blocks[blockIndex].baseUri = overrideUri;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default RequestHandlerArgs;
|
|
@@ -38,7 +38,7 @@ class GitHubCliModuleProvider {
|
|
|
38
38
|
this.repo = repo;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
async FindLatestRelease() {
|
|
41
|
+
async FindLatestRelease(version?: string) {
|
|
42
42
|
const { http, latest_release_url, releases_url } = this;
|
|
43
43
|
// return latest tag version is:
|
|
44
44
|
|
|
@@ -56,14 +56,18 @@ class GitHubCliModuleProvider {
|
|
|
56
56
|
throw new Error(`Unable to get releases`, { cause: releasesErr });
|
|
57
57
|
} else if (!releases || releases.length === 0)
|
|
58
58
|
throw new Error(`No releases available`);
|
|
59
|
-
else if (
|
|
59
|
+
else if (version) {
|
|
60
|
+
const release = releases.find(
|
|
61
|
+
r => r.tag_name.toLowerCase() === version.toLowerCase()
|
|
62
|
+
);
|
|
63
|
+
if (release) return release;
|
|
64
|
+
else throw new Error(`No release for ${version} found`);
|
|
65
|
+
} else if (latestErr && !latest) {
|
|
60
66
|
if (latestResponse?.status === 404 && releases?.length) {
|
|
61
67
|
// No latest release, check releases for prerelease version, fallback to last release
|
|
62
68
|
const release = releases.find(r => r.prerelease) || releases[0];
|
|
63
69
|
|
|
64
|
-
if (release)
|
|
65
|
-
return release;
|
|
66
|
-
}
|
|
70
|
+
if (release) return release;
|
|
67
71
|
}
|
|
68
72
|
} else {
|
|
69
73
|
return latest;
|
|
@@ -110,7 +114,7 @@ class GitHubCliModuleProvider {
|
|
|
110
114
|
removeFile(filePath);
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
addExecutePermission(joinPath(path, cmd));
|
|
117
|
+
if (os.platform() !== 'win32') addExecutePermission(joinPath(path, cmd));
|
|
114
118
|
} else
|
|
115
119
|
throw new Error(
|
|
116
120
|
`no asset found in release ${
|
|
@@ -94,6 +94,7 @@ export const cwdPath = (filePath: string) =>
|
|
|
94
94
|
export const joinPath = path.join;
|
|
95
95
|
|
|
96
96
|
export const addExecutePermission = (filePath: string) =>
|
|
97
|
+
// Fails in windows with `TypeError [ERR_INVALID_ARG_TYPE]: The "mode" argument must be of type number. Received undefined`
|
|
97
98
|
fs.chmodSync(filePath, fs.constants.S_IRWXU);
|
|
98
99
|
|
|
99
100
|
type DetectedFileType =
|
|
@@ -11,7 +11,7 @@ import { createRequestHandler } from '~/factories/RequestHandlerFactory';
|
|
|
11
11
|
import { OutputOptionsConstructorArg } from '~/models/CliService';
|
|
12
12
|
import { EnvContentsToAdd } from '~/models/DevService';
|
|
13
13
|
import { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';
|
|
14
|
-
import
|
|
14
|
+
import RequestHandlerArgs from '~/mappers/DevRequests-to-RequestHanderCliArgs';
|
|
15
15
|
import { deployKeyRole } from '~/mappers/DevInit-to-RolePermissions';
|
|
16
16
|
import { readFile, writeFile } from '~/providers/file-provider';
|
|
17
17
|
import { diffFileContent } from '~/util/diff';
|
|
@@ -412,8 +412,9 @@ class ContensisDev extends ContensisRole {
|
|
|
412
412
|
};
|
|
413
413
|
|
|
414
414
|
ExecRequestHandler = async (
|
|
415
|
-
|
|
416
|
-
overrideArgs: string[] = []
|
|
415
|
+
blockId: string[],
|
|
416
|
+
overrideArgs: string[] = [],
|
|
417
|
+
version?: string
|
|
417
418
|
) => {
|
|
418
419
|
const { debug, log, messages } = this;
|
|
419
420
|
|
|
@@ -422,15 +423,45 @@ class ContensisDev extends ContensisRole {
|
|
|
422
423
|
: log.info(messages.devrequests.launch());
|
|
423
424
|
|
|
424
425
|
// Ensure request handler is available to use
|
|
425
|
-
const requestHandler = await createRequestHandler();
|
|
426
|
+
const requestHandler = await createRequestHandler(version);
|
|
426
427
|
|
|
427
428
|
// Generate args for request handler using CLI methods
|
|
429
|
+
const args = new RequestHandlerArgs(this);
|
|
428
430
|
spinner?.start();
|
|
429
|
-
|
|
431
|
+
await args.Create();
|
|
430
432
|
spinner?.success();
|
|
431
433
|
|
|
434
|
+
// Prompt block id and dev uri to run locally (if not supplied)
|
|
435
|
+
const blockIdChoices = args.siteConfig?.blocks.map(block => block.id) || [];
|
|
436
|
+
blockIdChoices.push('none');
|
|
437
|
+
const defaultDeveloperUri = 'http://localhost:3000';
|
|
438
|
+
|
|
439
|
+
const { overrideBlockId, overrideUri } = blockId.length
|
|
440
|
+
? {
|
|
441
|
+
overrideBlockId: blockId[0],
|
|
442
|
+
overrideUri: blockId?.[1] || defaultDeveloperUri,
|
|
443
|
+
}
|
|
444
|
+
: await inquirer.prompt([
|
|
445
|
+
{
|
|
446
|
+
type: 'list',
|
|
447
|
+
prefix: '🧱',
|
|
448
|
+
message: messages.devrequests.overrideBlock(),
|
|
449
|
+
name: 'overrideBlockId',
|
|
450
|
+
choices: blockIdChoices,
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
type: 'input',
|
|
454
|
+
prefix: '🔗',
|
|
455
|
+
message: messages.devrequests.overrideUri(),
|
|
456
|
+
name: 'overrideUri',
|
|
457
|
+
default: defaultDeveloperUri,
|
|
458
|
+
},
|
|
459
|
+
]);
|
|
460
|
+
|
|
461
|
+
args.overrideBlock(overrideBlockId, overrideUri);
|
|
462
|
+
|
|
432
463
|
// Launch request handler
|
|
433
|
-
await requestHandler(args);
|
|
464
|
+
await requestHandler(args.getArgs(overrideArgs));
|
|
434
465
|
};
|
|
435
466
|
}
|
|
436
467
|
export const devCommand = (
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.1.2-beta.
|
|
1
|
+
export const LIB_VERSION = "1.1.2-beta.3";
|