Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ coverage
oclif.manifest.json
package-lock.json

bin/openwhisk-standalone*.jar
55 changes: 0 additions & 55 deletions bin/openwhisk-standalone-config/get-runtimes.js

This file was deleted.

55 changes: 0 additions & 55 deletions bin/openwhisk-standalone-config/runtimes.json

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"archiver": "^5.3.1",
"chalk": "^4",
"chokidar": "^3.5.2",
"debug": "^4.1.1",
"dedent-js": "^1.0.1",
"dotenv": "^16",
"execa": "^5.0.0",
"fs-extra": "^11.1.1",
"get-port": "^5",
Expand Down
3 changes: 1 addition & 2 deletions src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ class Deploy extends BuildCommand {
if (!script) {
const hookResults = await this.config.runHook('deploy-actions', {
appConfig: config,
filterEntities: filterActions || [],
isLocalDev: false
filterEntities: filterActions || []
})
if (hookResults?.failures?.length > 0) {
// output should be "Error : <plugin-name> : <error-message>\n" for each failure
Expand Down
18 changes: 4 additions & 14 deletions src/commands/app/get-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const BaseCommand = require('../../BaseCommand')
const { wrapError } = require('../../lib/app-helper')
const { getActionUrls } = require('@adobe/aio-lib-runtime').utils
const yaml = require('js-yaml')
const { loadLocalDevConfig } = require('../../lib/run-local-runtime')

class GetUrlCommand extends BaseCommand {
async run () {
Expand Down Expand Up @@ -46,16 +45,10 @@ class GetUrlCommand extends BaseCommand {
}

const actionUrls = {}
if (flags.local) {
Object.values(fullConfig.all).forEach(config => {
const localDevConfig = loadLocalDevConfig(config)
Object.assign(actionUrls, getActionUrls(localDevConfig, false, true))
})
} else {
Object.values(fullConfig.all).forEach(config => {
Object.assign(actionUrls, getActionUrls(config, true))
})
}

Object.values(fullConfig.all).forEach(config => {
Object.assign(actionUrls, getActionUrls(config, true))
})
urls.runtime = actionUrls
const cdnUrls = {}
if (options.cdn) {
Expand Down Expand Up @@ -110,9 +103,6 @@ GetUrlCommand.flags = {
yml: Flags.boolean({
description: 'Output yml',
char: 'y'
}),
local: Flags.boolean({
description: 'Display locally based action URLs'
})
}

Expand Down
18 changes: 1 addition & 17 deletions src/commands/app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const fs = require('fs-extra')
const https = require('https')
const getPort = require('get-port')
const open = require('open')
const os = require('node:os')

const { Flags, ux } = require('@oclif/core')
const coreConfig = require('@adobe/aio-lib-core-config')
Expand All @@ -36,16 +35,6 @@ class Run extends BaseCommand {
// cli input
const { flags } = await this.parse(Run)

if (flags.local) {
const [firstCpu] = os.cpus()
// note: the earliest versions of M1 macs return 'Apple processor' under model.
if (firstCpu?.model?.startsWith('Apple')) {
this.error('The --local flag is not supported on Apple Silicon Macs.')
} else {
this.warn('The --local flag is deprecated and will be removed in the next major release.')
}
}

const spinner = ora()

const runConfigs = await this.getAppExtConfigs(flags)
Expand Down Expand Up @@ -87,7 +76,6 @@ class Run extends BaseCommand {
shouldContentHash: false
},
fetchLogs: true,
isLocal: flags.local,
verbose: flags.verbose
}

Expand All @@ -107,7 +95,7 @@ class Run extends BaseCommand {
}
}

const verboseOutput = flags.verbose || flags.local || headlessApp
const verboseOutput = flags.verbose || headlessApp
// we should evaluate this, a lot of output just disappears in the spinner text and
// using verbose dumps ALL of parcel's output, so this become unreadable
// we need a middle ground. -jm
Expand Down Expand Up @@ -217,10 +205,6 @@ Run.args = {}

Run.flags = {
...BaseCommand.flags,
local: Flags.boolean({
description: '[deprecated] Run/debug actions locally (requires Docker running, not available on Apple Silicon Macs)',
exclusive: ['no-actions']
}),
serve: Flags.boolean({
description: '[default: true] Start frontend server (experimental)',
default: true,
Expand Down
4 changes: 1 addition & 3 deletions src/lib/actions-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const deployActions = require('./deploy-actions')
/**
* @typedef {object} WatcherOptions
* @property {object} config the app config (see src/lib/config-loader.js)
* @property {boolean} isLocal whether the deployment is local or not
* @property {Function} log the app logger
* @property {object} [watcher] the watcher itself
*/
Expand Down Expand Up @@ -61,10 +60,9 @@ module.exports = async (watcherOptions) => {
* @param {Array<string>} filterActions add filters to deploy only specified OpenWhisk actions
*/
async function buildAndDeploy (watcherOptions, filterActions) {
const { config, isLocal, log, inprocHook } = watcherOptions
const { config, log, inprocHook } = watcherOptions
await buildActions(config, filterActions)
const deployConfig = {
isLocalDev: isLocal,
filterEntities: {
actions: filterActions
}
Expand Down
117 changes: 0 additions & 117 deletions src/lib/app-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const which = require('which')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:lib-app-helper', { provider: 'debug' })
const { getToken, context } = require('@adobe/aio-lib-ims')
const { CLI } = require('@adobe/aio-lib-ims/src/context')
const { createFetch } = require('@adobe/aio-lib-core-networking')
const chalk = require('chalk')
const aioConfig = require('@adobe/aio-lib-core-config')
const { AIO_CONFIG_WORKSPACE_SERVICES, AIO_CONFIG_ORG_SERVICES } = require('./defaults')
Expand Down Expand Up @@ -262,116 +261,6 @@ function writeConfig (file, config) {
)
}

/** @private */
async function isDockerRunning () {
// todo more checks
const args = ['info']
try {
await execa('docker', args)
return true
} catch (error) {
aioLogger.debug('Error spawning docker info: ' + error)
}
return false
}

/** @private */
async function hasDockerCLI () {
// todo check min version
try {
const result = await execa('docker', ['-v'])
aioLogger.debug('docker version : ' + result.stdout)
return true
} catch (error) {
aioLogger.debug('Error spawning docker info: ' + error)
}
return false
}

/** @private */
async function hasJavaCLI () {
// todo check min version
try {
const result = await execa('java', ['-version'])
// stderr is where the version is printed out for
aioLogger.debug('java version : ' + result.stderr)
return true
} catch (error) {
aioLogger.debug('Error spawning java info: ' + error)
}
return false
}

/** @private */
async function downloadOWJar (url, outFile) {
aioLogger.debug(`downloadOWJar - url: ${url} outFile: ${outFile}`)
let response
try {
const fetch = createFetch()
response = await fetch(url)
} catch (e) {
aioLogger.debug(`connection error while downloading '${url}'`, e)
throw new Error(`connection error while downloading '${url}', are you online?`)
}
if (!response.ok) throw new Error(`unexpected response while downloading '${url}': ${response.statusText}`)
fs.ensureDirSync(path.dirname(outFile))
const fstream = fs.createWriteStream(outFile)

return new Promise((resolve, reject) => {
response.body.pipe(fstream)
response.body.on('error', (err) => {
reject(err)
})
fstream.on('finish', () => {
resolve()
})
})
}

/** @private */
async function waitForOpenWhiskReadiness (host, endTime, period, timeout, lastStatus, waitFunc) {
if (Date.now() > endTime) {
throw new Error(`local openwhisk stack startup timed out after ${timeout}ms due to ${lastStatus}`)
}

let ok, status

try {
const fetch = createFetch()
const response = await fetch(host + '/api/v1')
ok = response.ok
status = response.statusText
} catch (e) {
ok = false
status = e.toString()
}

if (!ok) {
await waitFunc(period)
return waitForOpenWhiskReadiness(host, endTime, period, timeout, status, waitFunc)
}
}

/** @private */
function waitFor (t) {
return new Promise(resolve => setTimeout(resolve, t))
}

/** @private */
async function runOpenWhiskJar (jarFile, runtimeConfigFile, apihost, waitInitTime, waitPeriodTime, timeout, /* istanbul ignore next */ execaOptions = {}) {
aioLogger.debug(`runOpenWhiskJar - jarFile: ${jarFile} runtimeConfigFile ${runtimeConfigFile} apihost: ${apihost} waitInitTime: ${waitInitTime} waitPeriodTime: ${waitPeriodTime} timeout: ${timeout}`)
const jvmConfig = aioConfig.get('ow.jvm.args')
const jvmArgs = jvmConfig ? jvmConfig.split(' ') : []
const proc = execa('java', ['-jar', '-Dwhisk.concurrency-limit.max=10', ...jvmArgs, jarFile, '-m', runtimeConfigFile, '--no-ui', '--disable-color-logging'], execaOptions)

const endTime = Date.now() + timeout
await waitFor(waitInitTime)
await waitForOpenWhiskReadiness(apihost, endTime, waitPeriodTime, timeout, null, waitFor)

// must wrap in an object as execa return value is awaitable
return { proc }
}

/**
*
*Converts a service array to an input string that can be consumed by generator-aio-app
Expand Down Expand Up @@ -599,14 +488,8 @@ module.exports = {
removeProtocolFromURL,
urlJoin,
checkFile,
hasDockerCLI,
hasJavaCLI,
isDockerRunning,
writeConfig,
downloadOWJar,
runOpenWhiskJar,
servicesToGeneratorInput,
waitForOpenWhiskReadiness,
warnIfOverwriteServicesInProductionWorkspace,
setOrgServicesConfig,
setWorkspaceServicesConfig,
Expand Down
Loading