@adobe/aio-cli-plugin-app 13.3.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 +3 -7
- 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/deploy.js +1 -2
- 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/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/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
|
@@ -185,8 +185,7 @@ class Deploy extends BuildCommand {
|
|
|
185
185
|
if (!script) {
|
|
186
186
|
const hookResults = await this.config.runHook('deploy-actions', {
|
|
187
187
|
appConfig: config,
|
|
188
|
-
filterEntities: filterActions || []
|
|
189
|
-
isLocalDev: false
|
|
188
|
+
filterEntities: filterActions || []
|
|
190
189
|
})
|
|
191
190
|
if (hookResults?.failures?.length > 0) {
|
|
192
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,
|
|
@@ -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')
|
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
|
-
}
|
package/src/lib/owlocal.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 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
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const path = require('path')
|
|
14
|
-
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:owlocal', { provider: 'debug' })
|
|
15
|
-
const execa = require('execa')
|
|
16
|
-
const url = require('url')
|
|
17
|
-
|
|
18
|
-
const OW_LOCAL_DOCKER_PORT = 3233
|
|
19
|
-
|
|
20
|
-
/** @private */
|
|
21
|
-
function isWindowsOrMac () {
|
|
22
|
-
return (
|
|
23
|
-
process.platform === 'win32' ||
|
|
24
|
-
process.platform === 'darwin'
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @private */
|
|
29
|
-
function owJarPath (owJarUrl) {
|
|
30
|
-
const { pathname } = new url.URL(owJarUrl)
|
|
31
|
-
const idx = pathname.indexOf('/openwhisk/')
|
|
32
|
-
let jarPath
|
|
33
|
-
|
|
34
|
-
if (idx === -1) {
|
|
35
|
-
jarPath = path.join('openwhisk', 'openwhisk-standalone.jar') // default path
|
|
36
|
-
aioLogger.warn(`Could not parse openwhisk jar path from ${owJarUrl}, using default ${jarPath}`)
|
|
37
|
-
} else {
|
|
38
|
-
jarPath = pathname
|
|
39
|
-
.substring(idx + 1) // skip initial forward slash
|
|
40
|
-
.split(path.posix.sep) // split on forward slashes
|
|
41
|
-
.join(path.sep) // join on os path separator (for Windows)
|
|
42
|
-
aioLogger.debug(`Parsed openwhisk jar path from ${owJarUrl}, using ${jarPath}`)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return jarPath
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** @private */
|
|
49
|
-
function getDockerNetworkAddress () {
|
|
50
|
-
try {
|
|
51
|
-
// Docker for Windows and macOS do not allow routing to the containers via
|
|
52
|
-
// IP address, only port forwarding is allowed
|
|
53
|
-
if (!isWindowsOrMac()) {
|
|
54
|
-
const args = ['network', 'inspect', 'bridge']
|
|
55
|
-
const result = execa.sync('docker', args)
|
|
56
|
-
const json = JSON.parse(result.stdout)
|
|
57
|
-
return `http://${json[0].IPAM.Config[0].Gateway}:${OW_LOCAL_DOCKER_PORT}`
|
|
58
|
-
}
|
|
59
|
-
} catch (error) {
|
|
60
|
-
aioLogger.debug(`getDockerNetworkAddress ${error}`)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return `http://localhost:${OW_LOCAL_DOCKER_PORT}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// gets these values if the keys are set in the environment, if not it will use the defaults set
|
|
67
|
-
const {
|
|
68
|
-
OW_JAR_URL = 'https://github.com/adobe/aio-cli-plugin-app/releases/download/6.2.0/openwhisk-standalone.jar',
|
|
69
|
-
OW_CONFIG_RUNTIMES_FILE = path.resolve(__dirname, '../../bin/openwhisk-standalone-config/runtimes.json'),
|
|
70
|
-
OW_LOCAL_APIHOST = getDockerNetworkAddress(),
|
|
71
|
-
OW_LOCAL_NAMESPACE = 'guest',
|
|
72
|
-
OW_LOCAL_AUTH = '23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP',
|
|
73
|
-
OW_LOCAL_LOG_FILE
|
|
74
|
-
} = process.env
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
getDockerNetworkAddress,
|
|
78
|
-
OW_LOCAL_DOCKER_PORT,
|
|
79
|
-
OW_JAR_URL,
|
|
80
|
-
OW_JAR_PATH: owJarPath(OW_JAR_URL),
|
|
81
|
-
OW_CONFIG_RUNTIMES_FILE,
|
|
82
|
-
OW_LOCAL_APIHOST,
|
|
83
|
-
OW_LOCAL_NAMESPACE,
|
|
84
|
-
OW_LOCAL_AUTH,
|
|
85
|
-
OW_LOCAL_LOG_FILE
|
|
86
|
-
}
|