@adobe/aio-cli-plugin-app 13.2.0 → 14.0.0
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/README.md +61 -37
- package/oclif.manifest.json +73 -54
- package/package.json +4 -8
- package/src/TemplatesCommand.js +1 -1
- package/src/commands/app/build.js +1 -1
- package/src/commands/app/clean-build.js +110 -0
- package/src/commands/app/config/set/log-forwarding.js +7 -1
- package/src/commands/app/deploy.js +8 -4
- package/src/commands/app/get-url.js +4 -14
- package/src/commands/app/init.js +1 -1
- package/src/commands/app/run.js +1 -17
- package/src/commands/app/undeploy.js +4 -1
- package/src/lib/actions-watcher.js +1 -3
- package/src/lib/app-helper.js +0 -117
- package/src/lib/audit-logger.js +0 -1
- package/src/lib/auth-helper.js +63 -0
- package/src/lib/defaults.js +4 -1
- package/src/lib/run-dev.js +6 -23
- package/bin/openwhisk-standalone-config/get-runtimes.js +0 -55
- package/bin/openwhisk-standalone-config/runtimes.json +0 -55
- package/src/lib/owlocal.js +0 -86
- package/src/lib/run-local-runtime.js +0 -154
- package/src/lib/vscode.js +0 -85
|
@@ -12,10 +12,16 @@ governing permissions and limitations under the License.
|
|
|
12
12
|
const BaseCommand = require('../../../../BaseCommand')
|
|
13
13
|
const LogForwarding = require('../../../../lib/log-forwarding')
|
|
14
14
|
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:lf:set', { provider: 'debug' })
|
|
15
|
+
const { setRuntimeApiHostAndAuthHandler } = require('../../../../lib/auth-helper')
|
|
15
16
|
|
|
16
17
|
class LogForwardingCommand extends BaseCommand {
|
|
17
18
|
async run () {
|
|
18
|
-
|
|
19
|
+
let aioConfig = (await this.getFullConfig()).aio
|
|
20
|
+
// TODO: remove this check once the deploy service is enabled by default
|
|
21
|
+
if (process.env.IS_DEPLOY_SERVICE_ENABLED === 'true') {
|
|
22
|
+
aioConfig = setRuntimeApiHostAndAuthHandler(aioConfig)
|
|
23
|
+
}
|
|
24
|
+
const lf = await LogForwarding.init(aioConfig)
|
|
19
25
|
|
|
20
26
|
const destination = await this.promptDestination(lf.getSupportedDestinations())
|
|
21
27
|
const destinationSettingsConfig = lf.getSettingsConfig(destination)
|
|
@@ -22,6 +22,7 @@ const { runInProcess, buildExtensionPointPayloadWoMetadata, buildExcShellViewExt
|
|
|
22
22
|
const rtLib = require('@adobe/aio-lib-runtime')
|
|
23
23
|
const LogForwarding = require('../../lib/log-forwarding')
|
|
24
24
|
const { sendAuditLogs, getAuditLogEvent, getFilesCountWithExtension } = require('../../lib/audit-logger')
|
|
25
|
+
const { setRuntimeApiHostAndAuthHandler } = require('../../lib/auth-helper')
|
|
25
26
|
const logActions = require('../../lib/log-actions')
|
|
26
27
|
|
|
27
28
|
const PRE_DEPLOY_EVENT_REG = 'pre-deploy-event-reg'
|
|
@@ -100,7 +101,8 @@ class Deploy extends BuildCommand {
|
|
|
100
101
|
// - break into smaller pieces deploy, allowing to first deploy all actions then all web assets
|
|
101
102
|
for (let i = 0; i < keys.length; ++i) {
|
|
102
103
|
const k = keys[i]
|
|
103
|
-
const v = values[i]
|
|
104
|
+
const v = setRuntimeApiHostAndAuthHandler(values[i])
|
|
105
|
+
|
|
104
106
|
await this.deploySingleConfig(k, v, flags, spinner)
|
|
105
107
|
if (v.app.hasFrontend && flags['web-assets']) {
|
|
106
108
|
const opItems = getFilesCountWithExtension(v.web.distProd)
|
|
@@ -111,7 +113,10 @@ class Deploy extends BuildCommand {
|
|
|
111
113
|
// only send logs in case of web-assets deployment
|
|
112
114
|
await sendAuditLogs(cliDetails.accessToken, assetDeployedLogEvent, cliDetails.env)
|
|
113
115
|
} catch (error) {
|
|
114
|
-
|
|
116
|
+
if (flags.verbose) {
|
|
117
|
+
this.warn('Error: Audit Log Service Error: Failed to send audit log event for deployment.')
|
|
118
|
+
this.warn(error.message)
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
}
|
|
@@ -180,8 +185,7 @@ class Deploy extends BuildCommand {
|
|
|
180
185
|
if (!script) {
|
|
181
186
|
const hookResults = await this.config.runHook('deploy-actions', {
|
|
182
187
|
appConfig: config,
|
|
183
|
-
filterEntities: filterActions || []
|
|
184
|
-
isLocalDev: false
|
|
188
|
+
filterEntities: filterActions || []
|
|
185
189
|
})
|
|
186
190
|
if (hookResults?.failures?.length > 0) {
|
|
187
191
|
// output should be "Error : <plugin-name> : <error-message>\n" for each failure
|
|
@@ -18,7 +18,6 @@ const BaseCommand = require('../../BaseCommand')
|
|
|
18
18
|
const { wrapError } = require('../../lib/app-helper')
|
|
19
19
|
const { getActionUrls } = require('@adobe/aio-lib-runtime').utils
|
|
20
20
|
const yaml = require('js-yaml')
|
|
21
|
-
const { loadLocalDevConfig } = require('../../lib/run-local-runtime')
|
|
22
21
|
|
|
23
22
|
class GetUrlCommand extends BaseCommand {
|
|
24
23
|
async run () {
|
|
@@ -46,16 +45,10 @@ class GetUrlCommand extends BaseCommand {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const actionUrls = {}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
} else {
|
|
55
|
-
Object.values(fullConfig.all).forEach(config => {
|
|
56
|
-
Object.assign(actionUrls, getActionUrls(config, true))
|
|
57
|
-
})
|
|
58
|
-
}
|
|
48
|
+
|
|
49
|
+
Object.values(fullConfig.all).forEach(config => {
|
|
50
|
+
Object.assign(actionUrls, getActionUrls(config, true))
|
|
51
|
+
})
|
|
59
52
|
urls.runtime = actionUrls
|
|
60
53
|
const cdnUrls = {}
|
|
61
54
|
if (options.cdn) {
|
|
@@ -110,9 +103,6 @@ GetUrlCommand.flags = {
|
|
|
110
103
|
yml: Flags.boolean({
|
|
111
104
|
description: 'Output yml',
|
|
112
105
|
char: 'y'
|
|
113
|
-
}),
|
|
114
|
-
local: Flags.boolean({
|
|
115
|
-
description: 'Display locally based action URLs'
|
|
116
106
|
})
|
|
117
107
|
}
|
|
118
108
|
|
package/src/commands/app/init.js
CHANGED
|
@@ -75,7 +75,7 @@ class InitCommand extends TemplatesCommand {
|
|
|
75
75
|
|
|
76
76
|
getInitialGenerators (flags) {
|
|
77
77
|
// TODO read from config to override
|
|
78
|
-
const initialGenerators = ['base-app', 'add-ci']
|
|
78
|
+
const initialGenerators = ['base-app', 'add-ci', 'add-vscode-config']
|
|
79
79
|
|
|
80
80
|
if (flags['standalone-app']) {
|
|
81
81
|
initialGenerators.push('application')
|
package/src/commands/app/run.js
CHANGED
|
@@ -16,7 +16,6 @@ const fs = require('fs-extra')
|
|
|
16
16
|
const https = require('https')
|
|
17
17
|
const getPort = require('get-port')
|
|
18
18
|
const open = require('open')
|
|
19
|
-
const os = require('node:os')
|
|
20
19
|
|
|
21
20
|
const { Flags, ux } = require('@oclif/core')
|
|
22
21
|
const coreConfig = require('@adobe/aio-lib-core-config')
|
|
@@ -36,16 +35,6 @@ class Run extends BaseCommand {
|
|
|
36
35
|
// cli input
|
|
37
36
|
const { flags } = await this.parse(Run)
|
|
38
37
|
|
|
39
|
-
if (flags.local) {
|
|
40
|
-
const [firstCpu] = os.cpus()
|
|
41
|
-
// note: the earliest versions of M1 macs return 'Apple processor' under model.
|
|
42
|
-
if (firstCpu?.model?.startsWith('Apple')) {
|
|
43
|
-
this.error('The --local flag is not supported on Apple Silicon Macs.')
|
|
44
|
-
} else {
|
|
45
|
-
this.warn('The --local flag is deprecated and will be removed in the next major release.')
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
38
|
const spinner = ora()
|
|
50
39
|
|
|
51
40
|
const runConfigs = await this.getAppExtConfigs(flags)
|
|
@@ -87,7 +76,6 @@ class Run extends BaseCommand {
|
|
|
87
76
|
shouldContentHash: false
|
|
88
77
|
},
|
|
89
78
|
fetchLogs: true,
|
|
90
|
-
isLocal: flags.local,
|
|
91
79
|
verbose: flags.verbose
|
|
92
80
|
}
|
|
93
81
|
|
|
@@ -107,7 +95,7 @@ class Run extends BaseCommand {
|
|
|
107
95
|
}
|
|
108
96
|
}
|
|
109
97
|
|
|
110
|
-
const verboseOutput = flags.verbose ||
|
|
98
|
+
const verboseOutput = flags.verbose || headlessApp
|
|
111
99
|
// we should evaluate this, a lot of output just disappears in the spinner text and
|
|
112
100
|
// using verbose dumps ALL of parcel's output, so this become unreadable
|
|
113
101
|
// we need a middle ground. -jm
|
|
@@ -217,10 +205,6 @@ Run.args = {}
|
|
|
217
205
|
|
|
218
206
|
Run.flags = {
|
|
219
207
|
...BaseCommand.flags,
|
|
220
|
-
local: Flags.boolean({
|
|
221
|
-
description: '[deprecated] Run/debug actions locally (requires Docker running, not available on Apple Silicon Macs)',
|
|
222
|
-
exclusive: ['no-actions']
|
|
223
|
-
}),
|
|
224
208
|
serve: Flags.boolean({
|
|
225
209
|
description: '[default: true] Start frontend server (experimental)',
|
|
226
210
|
default: true,
|
|
@@ -20,6 +20,7 @@ const webLib = require('@adobe/aio-lib-web')
|
|
|
20
20
|
const { runInProcess, buildExtensionPointPayloadWoMetadata, getCliInfo } = require('../../lib/app-helper')
|
|
21
21
|
const rtLib = require('@adobe/aio-lib-runtime')
|
|
22
22
|
const { sendAuditLogs, getAuditLogEvent } = require('../../lib/audit-logger')
|
|
23
|
+
const { setRuntimeApiHostAndAuthHandler } = require('../../lib/auth-helper')
|
|
23
24
|
|
|
24
25
|
class Undeploy extends BaseCommand {
|
|
25
26
|
async run () {
|
|
@@ -55,7 +56,9 @@ class Undeploy extends BaseCommand {
|
|
|
55
56
|
|
|
56
57
|
for (let i = 0; i < keys.length; ++i) {
|
|
57
58
|
const k = keys[i]
|
|
58
|
-
|
|
59
|
+
// TODO: remove this check once the deploy service is enabled by default
|
|
60
|
+
const v = process.env.IS_DEPLOY_SERVICE_ENABLED === 'true' ? setRuntimeApiHostAndAuthHandler(values[i]) : values[i]
|
|
61
|
+
|
|
59
62
|
await this.undeployOneExt(k, v, flags, spinner)
|
|
60
63
|
const assetUndeployLogEvent = getAuditLogEvent(flags, aioConfig.project, 'AB_APP_ASSETS_UNDEPLOYED')
|
|
61
64
|
// send logs for case of web-assets undeployment
|
|
@@ -24,7 +24,6 @@ const deployActions = require('./deploy-actions')
|
|
|
24
24
|
/**
|
|
25
25
|
* @typedef {object} WatcherOptions
|
|
26
26
|
* @property {object} config the app config (see src/lib/config-loader.js)
|
|
27
|
-
* @property {boolean} isLocal whether the deployment is local or not
|
|
28
27
|
* @property {Function} log the app logger
|
|
29
28
|
* @property {object} [watcher] the watcher itself
|
|
30
29
|
*/
|
|
@@ -61,10 +60,9 @@ module.exports = async (watcherOptions) => {
|
|
|
61
60
|
* @param {Array<string>} filterActions add filters to deploy only specified OpenWhisk actions
|
|
62
61
|
*/
|
|
63
62
|
async function buildAndDeploy (watcherOptions, filterActions) {
|
|
64
|
-
const { config,
|
|
63
|
+
const { config, log, inprocHook } = watcherOptions
|
|
65
64
|
await buildActions(config, filterActions)
|
|
66
65
|
const deployConfig = {
|
|
67
|
-
isLocalDev: isLocal,
|
|
68
66
|
filterEntities: {
|
|
69
67
|
actions: filterActions
|
|
70
68
|
}
|
package/src/lib/app-helper.js
CHANGED
|
@@ -16,7 +16,6 @@ const which = require('which')
|
|
|
16
16
|
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:lib-app-helper', { provider: 'debug' })
|
|
17
17
|
const { getToken, context } = require('@adobe/aio-lib-ims')
|
|
18
18
|
const { CLI } = require('@adobe/aio-lib-ims/src/context')
|
|
19
|
-
const { createFetch } = require('@adobe/aio-lib-core-networking')
|
|
20
19
|
const chalk = require('chalk')
|
|
21
20
|
const aioConfig = require('@adobe/aio-lib-core-config')
|
|
22
21
|
const { AIO_CONFIG_WORKSPACE_SERVICES, AIO_CONFIG_ORG_SERVICES } = require('./defaults')
|
|
@@ -262,116 +261,6 @@ function writeConfig (file, config) {
|
|
|
262
261
|
)
|
|
263
262
|
}
|
|
264
263
|
|
|
265
|
-
/** @private */
|
|
266
|
-
async function isDockerRunning () {
|
|
267
|
-
// todo more checks
|
|
268
|
-
const args = ['info']
|
|
269
|
-
try {
|
|
270
|
-
await execa('docker', args)
|
|
271
|
-
return true
|
|
272
|
-
} catch (error) {
|
|
273
|
-
aioLogger.debug('Error spawning docker info: ' + error)
|
|
274
|
-
}
|
|
275
|
-
return false
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** @private */
|
|
279
|
-
async function hasDockerCLI () {
|
|
280
|
-
// todo check min version
|
|
281
|
-
try {
|
|
282
|
-
const result = await execa('docker', ['-v'])
|
|
283
|
-
aioLogger.debug('docker version : ' + result.stdout)
|
|
284
|
-
return true
|
|
285
|
-
} catch (error) {
|
|
286
|
-
aioLogger.debug('Error spawning docker info: ' + error)
|
|
287
|
-
}
|
|
288
|
-
return false
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/** @private */
|
|
292
|
-
async function hasJavaCLI () {
|
|
293
|
-
// todo check min version
|
|
294
|
-
try {
|
|
295
|
-
const result = await execa('java', ['-version'])
|
|
296
|
-
// stderr is where the version is printed out for
|
|
297
|
-
aioLogger.debug('java version : ' + result.stderr)
|
|
298
|
-
return true
|
|
299
|
-
} catch (error) {
|
|
300
|
-
aioLogger.debug('Error spawning java info: ' + error)
|
|
301
|
-
}
|
|
302
|
-
return false
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/** @private */
|
|
306
|
-
async function downloadOWJar (url, outFile) {
|
|
307
|
-
aioLogger.debug(`downloadOWJar - url: ${url} outFile: ${outFile}`)
|
|
308
|
-
let response
|
|
309
|
-
try {
|
|
310
|
-
const fetch = createFetch()
|
|
311
|
-
response = await fetch(url)
|
|
312
|
-
} catch (e) {
|
|
313
|
-
aioLogger.debug(`connection error while downloading '${url}'`, e)
|
|
314
|
-
throw new Error(`connection error while downloading '${url}', are you online?`)
|
|
315
|
-
}
|
|
316
|
-
if (!response.ok) throw new Error(`unexpected response while downloading '${url}': ${response.statusText}`)
|
|
317
|
-
fs.ensureDirSync(path.dirname(outFile))
|
|
318
|
-
const fstream = fs.createWriteStream(outFile)
|
|
319
|
-
|
|
320
|
-
return new Promise((resolve, reject) => {
|
|
321
|
-
response.body.pipe(fstream)
|
|
322
|
-
response.body.on('error', (err) => {
|
|
323
|
-
reject(err)
|
|
324
|
-
})
|
|
325
|
-
fstream.on('finish', () => {
|
|
326
|
-
resolve()
|
|
327
|
-
})
|
|
328
|
-
})
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/** @private */
|
|
332
|
-
async function waitForOpenWhiskReadiness (host, endTime, period, timeout, lastStatus, waitFunc) {
|
|
333
|
-
if (Date.now() > endTime) {
|
|
334
|
-
throw new Error(`local openwhisk stack startup timed out after ${timeout}ms due to ${lastStatus}`)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
let ok, status
|
|
338
|
-
|
|
339
|
-
try {
|
|
340
|
-
const fetch = createFetch()
|
|
341
|
-
const response = await fetch(host + '/api/v1')
|
|
342
|
-
ok = response.ok
|
|
343
|
-
status = response.statusText
|
|
344
|
-
} catch (e) {
|
|
345
|
-
ok = false
|
|
346
|
-
status = e.toString()
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (!ok) {
|
|
350
|
-
await waitFunc(period)
|
|
351
|
-
return waitForOpenWhiskReadiness(host, endTime, period, timeout, status, waitFunc)
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/** @private */
|
|
356
|
-
function waitFor (t) {
|
|
357
|
-
return new Promise(resolve => setTimeout(resolve, t))
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** @private */
|
|
361
|
-
async function runOpenWhiskJar (jarFile, runtimeConfigFile, apihost, waitInitTime, waitPeriodTime, timeout, /* istanbul ignore next */ execaOptions = {}) {
|
|
362
|
-
aioLogger.debug(`runOpenWhiskJar - jarFile: ${jarFile} runtimeConfigFile ${runtimeConfigFile} apihost: ${apihost} waitInitTime: ${waitInitTime} waitPeriodTime: ${waitPeriodTime} timeout: ${timeout}`)
|
|
363
|
-
const jvmConfig = aioConfig.get('ow.jvm.args')
|
|
364
|
-
const jvmArgs = jvmConfig ? jvmConfig.split(' ') : []
|
|
365
|
-
const proc = execa('java', ['-jar', '-Dwhisk.concurrency-limit.max=10', ...jvmArgs, jarFile, '-m', runtimeConfigFile, '--no-ui', '--disable-color-logging'], execaOptions)
|
|
366
|
-
|
|
367
|
-
const endTime = Date.now() + timeout
|
|
368
|
-
await waitFor(waitInitTime)
|
|
369
|
-
await waitForOpenWhiskReadiness(apihost, endTime, waitPeriodTime, timeout, null, waitFor)
|
|
370
|
-
|
|
371
|
-
// must wrap in an object as execa return value is awaitable
|
|
372
|
-
return { proc }
|
|
373
|
-
}
|
|
374
|
-
|
|
375
264
|
/**
|
|
376
265
|
*
|
|
377
266
|
*Converts a service array to an input string that can be consumed by generator-aio-app
|
|
@@ -599,14 +488,8 @@ module.exports = {
|
|
|
599
488
|
removeProtocolFromURL,
|
|
600
489
|
urlJoin,
|
|
601
490
|
checkFile,
|
|
602
|
-
hasDockerCLI,
|
|
603
|
-
hasJavaCLI,
|
|
604
|
-
isDockerRunning,
|
|
605
491
|
writeConfig,
|
|
606
|
-
downloadOWJar,
|
|
607
|
-
runOpenWhiskJar,
|
|
608
492
|
servicesToGeneratorInput,
|
|
609
|
-
waitForOpenWhiskReadiness,
|
|
610
493
|
warnIfOverwriteServicesInProductionWorkspace,
|
|
611
494
|
setOrgServicesConfig,
|
|
612
495
|
setWorkspaceServicesConfig,
|
package/src/lib/audit-logger.js
CHANGED
|
@@ -8,7 +8,6 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
|
|
|
8
8
|
OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
9
|
governing permissions and limitations under the License.
|
|
10
10
|
*/
|
|
11
|
-
const fetch = require('node-fetch')
|
|
12
11
|
const fs = require('fs')
|
|
13
12
|
const path = require('path')
|
|
14
13
|
const chalk = require('chalk')
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
+
governing permissions and limitations under the License.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { getToken, context } = require('@adobe/aio-lib-ims')
|
|
13
|
+
const { CLI } = require('@adobe/aio-lib-ims/src/context')
|
|
14
|
+
const { getCliEnv } = require('@adobe/aio-lib-env')
|
|
15
|
+
const defaultRuntimeUrl = 'https://adobeioruntime.net'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* For use with the openwhisk client js library to send a bearer token instead of basic
|
|
19
|
+
* auth to the openwhisk service. Set this to the auth_handler option when initializing
|
|
20
|
+
*/
|
|
21
|
+
const bearerAuthHandler = {
|
|
22
|
+
getAuthHeader: async () => {
|
|
23
|
+
await context.setCli({ 'cli.bare-output': true }, false) // set this globally
|
|
24
|
+
|
|
25
|
+
const env = getCliEnv()
|
|
26
|
+
|
|
27
|
+
console.debug(`Retrieving CLI Token using env=${env}`)
|
|
28
|
+
const accessToken = await getToken(CLI)
|
|
29
|
+
|
|
30
|
+
return `Bearer ${accessToken}`
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const setRuntimeApiHostAndAuthHandler = (config) => {
|
|
35
|
+
// TODO: remove this check once the deploy service is enabled by default
|
|
36
|
+
if (process.env.IS_DEPLOY_SERVICE_ENABLED === 'true') {
|
|
37
|
+
const aioConfig = (config && 'runtime' in config) ? config : null
|
|
38
|
+
if (aioConfig) {
|
|
39
|
+
aioConfig.runtime.apihost = process.env.AIO_RUNTIME_APIHOST ?? defaultRuntimeUrl
|
|
40
|
+
aioConfig.runtime.auth_handler = bearerAuthHandler
|
|
41
|
+
return aioConfig
|
|
42
|
+
}
|
|
43
|
+
const owConfig = (config && 'ow' in config) ? config : null
|
|
44
|
+
if (owConfig) {
|
|
45
|
+
owConfig.ow.apihost = process.env.AIO_RUNTIME_APIHOST ?? defaultRuntimeUrl
|
|
46
|
+
owConfig.ow.auth_handler = bearerAuthHandler
|
|
47
|
+
return owConfig
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (config && config.runtime) {
|
|
51
|
+
config.runtime.apihost = process.env.AIO_RUNTIME_APIHOST ?? defaultRuntimeUrl
|
|
52
|
+
}
|
|
53
|
+
if (config && config.ow) {
|
|
54
|
+
config.ow.apihost = process.env.AIO_RUNTIME_APIHOST ?? defaultRuntimeUrl
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return config
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
bearerAuthHandler,
|
|
62
|
+
setRuntimeApiHostAndAuthHandler
|
|
63
|
+
}
|
package/src/lib/defaults.js
CHANGED
|
@@ -36,5 +36,8 @@ module.exports = {
|
|
|
36
36
|
LEGACY_RUNTIME_MANIFEST: 'manifest.yml',
|
|
37
37
|
INCLUDE_DIRECTIVE: '$include',
|
|
38
38
|
APPLICATION_CONFIG_KEY: 'application',
|
|
39
|
-
EXTENSIONS_CONFIG_KEY: 'extensions'
|
|
39
|
+
EXTENSIONS_CONFIG_KEY: 'extensions',
|
|
40
|
+
// Adding tracking file constants
|
|
41
|
+
LAST_BUILT_ACTIONS_FILENAME: 'last-built-actions.json',
|
|
42
|
+
LAST_DEPLOYED_ACTIONS_FILENAME: 'last-deployed-actions.json'
|
|
40
43
|
}
|
package/src/lib/run-dev.js
CHANGED
|
@@ -13,13 +13,11 @@ governing permissions and limitations under the License.
|
|
|
13
13
|
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:runDev', { provider: 'debug' })
|
|
14
14
|
const rtLib = require('@adobe/aio-lib-runtime')
|
|
15
15
|
const rtLibUtils = rtLib.utils
|
|
16
|
-
const vscode = require('./vscode')
|
|
17
16
|
const { bundle } = require('@adobe/aio-lib-web')
|
|
18
17
|
const bundleServe = require('./bundle-serve')
|
|
19
18
|
const { defaultHttpServerPort: SERVER_DEFAULT_PORT } = require('./defaults')
|
|
20
19
|
const serve = require('./serve')
|
|
21
20
|
const Cleanup = require('./cleanup')
|
|
22
|
-
const { runLocalRuntime } = require('./run-local-runtime')
|
|
23
21
|
|
|
24
22
|
const buildActions = require('./build-actions')
|
|
25
23
|
const deployActions = require('./deploy-actions')
|
|
@@ -47,7 +45,6 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
47
45
|
// control variables
|
|
48
46
|
const hasFrontend = config.app.hasFrontend
|
|
49
47
|
const withBackend = config.app.hasBackend && !skipActions
|
|
50
|
-
const isLocal = options.isLocal // applies only for backend
|
|
51
48
|
const portToUse = parseInt(process.env.PORT) || SERVER_DEFAULT_PORT
|
|
52
49
|
|
|
53
50
|
const uiPort = await getPort({ port: portToUse })
|
|
@@ -56,12 +53,11 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
56
53
|
}
|
|
57
54
|
aioLogger.debug(`hasFrontend ${hasFrontend}`)
|
|
58
55
|
aioLogger.debug(`withBackend ${withBackend}`)
|
|
59
|
-
aioLogger.debug(`isLocal ${isLocal}`)
|
|
60
56
|
|
|
61
57
|
let frontEndUrl
|
|
62
58
|
|
|
63
59
|
// state
|
|
64
|
-
|
|
60
|
+
const devConfig = config // config will be different if local or remote
|
|
65
61
|
devConfig.envFile = '.env'
|
|
66
62
|
|
|
67
63
|
const cleanup = new Cleanup()
|
|
@@ -70,20 +66,14 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
70
66
|
try {
|
|
71
67
|
// Build Phase - actions
|
|
72
68
|
if (withBackend) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
cleanup.add(() => localCleanup(), 'cleaning up runDevLocal')
|
|
77
|
-
} else {
|
|
78
|
-
// check credentials
|
|
79
|
-
rtLibUtils.checkOpenWhiskCredentials(devConfig)
|
|
80
|
-
log('using remote actions')
|
|
81
|
-
}
|
|
69
|
+
// check credentials
|
|
70
|
+
rtLibUtils.checkOpenWhiskCredentials(devConfig)
|
|
71
|
+
log('using remote actions')
|
|
82
72
|
|
|
83
73
|
// build and deploy actions
|
|
84
74
|
log('building actions..')
|
|
85
75
|
await buildActions(devConfig, null, false /* force build */)
|
|
86
|
-
const { cleanup: watcherCleanup } = await actionsWatcher({ config: devConfig,
|
|
76
|
+
const { cleanup: watcherCleanup } = await actionsWatcher({ config: devConfig, log, inprocHook })
|
|
87
77
|
cleanup.add(() => watcherCleanup(), 'stopping action watcher...')
|
|
88
78
|
}
|
|
89
79
|
|
|
@@ -95,7 +85,7 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
95
85
|
// note the condition: we still write backend urls EVEN if skipActions is set
|
|
96
86
|
// the urls will always point to remotely deployed actions if skipActions is set
|
|
97
87
|
log('injecting backend urls into frontend config')
|
|
98
|
-
urls = rtLibUtils.getActionUrls(devConfig, true,
|
|
88
|
+
urls = rtLibUtils.getActionUrls(devConfig, true, !skipActions, true)
|
|
99
89
|
}
|
|
100
90
|
utils.writeConfig(devConfig.web.injectedConfig, urls)
|
|
101
91
|
|
|
@@ -123,7 +113,6 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
123
113
|
if (withBackend) {
|
|
124
114
|
log('redeploying actions..')
|
|
125
115
|
const deployConfig = {
|
|
126
|
-
isLocalDev: isLocal,
|
|
127
116
|
filterEntities: {
|
|
128
117
|
byBuiltActions: true
|
|
129
118
|
}
|
|
@@ -166,12 +155,6 @@ async function runDev (config, dataDir, options = {}, log = () => {}, inprocHook
|
|
|
166
155
|
// also there was a latent issue with projects that defined an action src as a folder with an index.js file.
|
|
167
156
|
// it looks explicitly for package.json and fails if it does not find it.
|
|
168
157
|
// regarless, we don't need it, and when we actually remove --local we can be rid of this.
|
|
169
|
-
if (isLocal) {
|
|
170
|
-
log('setting up vscode debug configuration files...')
|
|
171
|
-
const vscodeConfig = vscode(devConfig)
|
|
172
|
-
await vscodeConfig.update({ frontEndUrl })
|
|
173
|
-
cleanup.add(() => vscodeConfig.cleanup(), 'cleaning up vscode debug configuration files...')
|
|
174
|
-
}
|
|
175
158
|
|
|
176
159
|
// automatically fetch logs if there are actions
|
|
177
160
|
if (config.app.hasBackend && fetchLogs) {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
-
governing permissions and limitations under the License.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const fetch = require('node-fetch')
|
|
13
|
-
|
|
14
|
-
const DOCKER_ORG = 'adobeapiplatform'
|
|
15
|
-
const DOCKER_REPOS = { // repo-name:kind
|
|
16
|
-
'adobe-action-nodejs-v10': 'nodejs:10',
|
|
17
|
-
'adobe-action-nodejs-v12': 'nodejs:12',
|
|
18
|
-
'adobe-action-nodejs-v14': 'nodejs:14',
|
|
19
|
-
'adobe-action-nodejs-v16': 'nodejs:16',
|
|
20
|
-
'adobe-action-nodejs-v18': 'nodejs:18',
|
|
21
|
-
'adobe-action-nodejs-v20': 'nodejs:20'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const DEFAULT_KIND = 'nodejs:18'
|
|
25
|
-
|
|
26
|
-
/** @private */
|
|
27
|
-
async function main () {
|
|
28
|
-
const nodejs = []
|
|
29
|
-
|
|
30
|
-
for (const [repoName, kind] of Object.entries(DOCKER_REPOS)) {
|
|
31
|
-
const data = await fetch(`https://registry.hub.docker.com/v2/repositories/${DOCKER_ORG}/${repoName}/tags`)
|
|
32
|
-
const json = await data.json()
|
|
33
|
-
const defaultKind = (kind === DEFAULT_KIND) ? true : undefined
|
|
34
|
-
|
|
35
|
-
nodejs.push({
|
|
36
|
-
kind,
|
|
37
|
-
default: defaultKind,
|
|
38
|
-
image: {
|
|
39
|
-
prefix: DOCKER_ORG,
|
|
40
|
-
name: repoName,
|
|
41
|
-
tag: json.results[0].name
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const output = {
|
|
47
|
-
runtimes: {
|
|
48
|
-
nodejs
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
console.log(JSON.stringify(output, null, 2))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
main()
|
|
55
|
-
.catch(console.error)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"runtimes": {
|
|
3
|
-
"nodejs": [
|
|
4
|
-
{
|
|
5
|
-
"kind": "nodejs:10",
|
|
6
|
-
"image": {
|
|
7
|
-
"prefix": "adobeapiplatform",
|
|
8
|
-
"name": "adobe-action-nodejs-v10",
|
|
9
|
-
"tag": "3.0.39"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"kind": "nodejs:12",
|
|
14
|
-
"image": {
|
|
15
|
-
"prefix": "adobeapiplatform",
|
|
16
|
-
"name": "adobe-action-nodejs-v12",
|
|
17
|
-
"tag": "3.0.39"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"kind": "nodejs:14",
|
|
22
|
-
"image": {
|
|
23
|
-
"prefix": "adobeapiplatform",
|
|
24
|
-
"name": "adobe-action-nodejs-v14",
|
|
25
|
-
"tag": "3.0.39"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"kind": "nodejs:16",
|
|
30
|
-
"image": {
|
|
31
|
-
"prefix": "adobeapiplatform",
|
|
32
|
-
"name": "adobe-action-nodejs-v16",
|
|
33
|
-
"tag": "3.0.39"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"kind": "nodejs:18",
|
|
38
|
-
"default": true,
|
|
39
|
-
"image": {
|
|
40
|
-
"prefix": "adobeapiplatform",
|
|
41
|
-
"name": "adobe-action-nodejs-v18",
|
|
42
|
-
"tag": "3.0.39"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"kind": "nodejs:20",
|
|
47
|
-
"image": {
|
|
48
|
-
"prefix": "adobeapiplatform",
|
|
49
|
-
"name": "adobe-action-nodejs-v20",
|
|
50
|
-
"tag": "3.0.39"
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|