adapt-cli 3.0.0 → 3.0.7
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/.bowerrc +2 -2
- package/.eslintignore +1 -1
- package/.eslintrc.json +14 -14
- package/.github/CONTRIBUTING.md +8 -0
- package/.github/ISSUE_TEMPLATE.md +17 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/addtomainproject.yml +19 -0
- package/.github/workflows/releases.yml +25 -0
- package/.travis.yml +46 -46
- package/README.md +266 -266
- package/bin/adapt.js +3 -3
- package/json/help-create/component.json +9 -9
- package/json/help-create/course.json +9 -9
- package/json/help-create/question.json +9 -9
- package/json/help-create.json +12 -12
- package/json/help-devinstall.json +9 -9
- package/json/help-install.json +10 -10
- package/json/help-ls.json +7 -7
- package/json/help-register.json +7 -7
- package/json/help-rename.json +7 -7
- package/json/help-search.json +8 -8
- package/json/help-uninstall.json +7 -7
- package/json/help-unregister.json +8 -8
- package/json/help-update.json +12 -12
- package/json/help-version.json +7 -7
- package/json/help.json +19 -19
- package/lib/api.js +273 -260
- package/lib/cli.js +70 -69
- package/lib/commands/authenticate.js +18 -18
- package/lib/commands/create/component.js +64 -64
- package/lib/commands/create/course.js +26 -26
- package/lib/commands/create/question.js +18 -18
- package/lib/commands/create.js +94 -85
- package/lib/commands/devinstall.js +35 -35
- package/lib/commands/help.js +31 -31
- package/lib/commands/install.js +16 -16
- package/lib/commands/ls.js +35 -9
- package/lib/commands/register.js +11 -11
- package/lib/commands/rename.js +14 -14
- package/lib/commands/search.js +11 -11
- package/lib/commands/uninstall.js +9 -9
- package/lib/commands/unregister.js +12 -12
- package/lib/commands/update.js +12 -12
- package/lib/commands/version.js +13 -13
- package/lib/econnreset.js +8 -0
- package/lib/integration/AdaptFramework/build.js +42 -39
- package/lib/integration/AdaptFramework/clone.js +27 -27
- package/lib/integration/AdaptFramework/deleteSrcCore.js +9 -9
- package/lib/integration/AdaptFramework/deleteSrcCourse.js +9 -9
- package/lib/integration/AdaptFramework/download.js +21 -21
- package/lib/integration/AdaptFramework/erase.js +34 -34
- package/lib/integration/AdaptFramework/getLatestVersion.js +74 -79
- package/lib/integration/AdaptFramework/npmInstall.js +21 -21
- package/lib/integration/AdaptFramework.js +19 -19
- package/lib/integration/Plugin.js +404 -403
- package/lib/integration/PluginManagement/autenticate.js +47 -56
- package/lib/integration/PluginManagement/install.js +224 -222
- package/lib/integration/PluginManagement/print.js +52 -52
- package/lib/integration/PluginManagement/register.js +130 -130
- package/lib/integration/PluginManagement/rename.js +95 -101
- package/lib/integration/PluginManagement/schemas.js +8 -8
- package/lib/integration/PluginManagement/search.js +37 -46
- package/lib/integration/PluginManagement/uninstall.js +141 -141
- package/lib/integration/PluginManagement/unregister.js +91 -101
- package/lib/integration/PluginManagement/update.js +224 -224
- package/lib/integration/PluginManagement.js +21 -21
- package/lib/integration/Project.js +146 -146
- package/lib/integration/Target.js +299 -296
- package/lib/integration/getBowerRegistryConfig.js +34 -34
- package/lib/logger.js +28 -28
- package/lib/util/JSONReadValidate.js +34 -34
- package/lib/util/constants.js +38 -38
- package/lib/util/createPromptTask.js +7 -7
- package/lib/util/download.js +45 -45
- package/lib/util/errors.js +58 -58
- package/lib/util/extract.js +24 -24
- package/lib/util/getDirNameFromImportMeta.js +6 -6
- package/lib/util/promises.js +36 -36
- package/package.json +74 -40
package/lib/commands/help.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import chalk from 'chalk'
|
|
4
|
-
import getDirNameFromImportMeta from '../util/getDirNameFromImportMeta.js'
|
|
5
|
-
const __dirname = getDirNameFromImportMeta(import.meta)
|
|
6
|
-
|
|
7
|
-
export default function help (logger, ...args) {
|
|
8
|
-
const name = args.join(' ')
|
|
9
|
-
const json = name
|
|
10
|
-
? path.resolve(__dirname, `../../json/help-${name.replace(/\s+/g, '/')}.json`)
|
|
11
|
-
: path.resolve(__dirname, '../../json/help.json')
|
|
12
|
-
if (!fs.existsSync(json)) {
|
|
13
|
-
logger?.log(`adapt ${chalk.red(name)} Unknown command: ${name}`)
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
const jsonData = fs.readJSONSync(json)
|
|
17
|
-
logger?.log('\nUsage: \n')
|
|
18
|
-
jsonData.usage.forEach(usage => logger?.log(` ${chalk.cyan('adapt')} ${usage}`))
|
|
19
|
-
if (jsonData.commands && Object.entries(jsonData.commands).length) {
|
|
20
|
-
logger?.log('\n\nwhere <command> is one of:\n')
|
|
21
|
-
Object.entries(jsonData.commands).forEach(([command, description]) => {
|
|
22
|
-
logger?.log(` ${command}${new Array(23 - command.length).join(' ')}${description}`)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
if (jsonData.description) {
|
|
26
|
-
logger?.log(`\nDescription:\n\n ${jsonData.description}`)
|
|
27
|
-
}
|
|
28
|
-
if (!name) {
|
|
29
|
-
logger?.log('\nSee \'adapt help <command>\' for more information on a specific command.\n')
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
import getDirNameFromImportMeta from '../util/getDirNameFromImportMeta.js'
|
|
5
|
+
const __dirname = getDirNameFromImportMeta(import.meta)
|
|
6
|
+
|
|
7
|
+
export default function help (logger, ...args) {
|
|
8
|
+
const name = args.join(' ')
|
|
9
|
+
const json = name
|
|
10
|
+
? path.resolve(__dirname, `../../json/help-${name.replace(/\s+/g, '/')}.json`)
|
|
11
|
+
: path.resolve(__dirname, '../../json/help.json')
|
|
12
|
+
if (!fs.existsSync(json)) {
|
|
13
|
+
logger?.log(`adapt ${chalk.red(name)} Unknown command: ${name}`)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
const jsonData = fs.readJSONSync(json)
|
|
17
|
+
logger?.log('\nUsage: \n')
|
|
18
|
+
jsonData.usage.forEach(usage => logger?.log(` ${chalk.cyan('adapt')} ${usage}`))
|
|
19
|
+
if (jsonData.commands && Object.entries(jsonData.commands).length) {
|
|
20
|
+
logger?.log('\n\nwhere <command> is one of:\n')
|
|
21
|
+
Object.entries(jsonData.commands).forEach(([command, description]) => {
|
|
22
|
+
logger?.log(` ${command}${new Array(23 - command.length).join(' ')}${description}`)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
if (jsonData.description) {
|
|
26
|
+
logger?.log(`\nDescription:\n\n ${jsonData.description}`)
|
|
27
|
+
}
|
|
28
|
+
if (!name) {
|
|
29
|
+
logger?.log('\nSee \'adapt help <command>\' for more information on a specific command.\n')
|
|
30
|
+
}
|
|
31
|
+
}
|
package/lib/commands/install.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { install as pluginsInstall } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function install (logger, ...args) {
|
|
4
|
-
/** strip flags */
|
|
5
|
-
const isClean = args.includes('--clean')
|
|
6
|
-
const isDryRun = args.includes('--dry-run') || args.includes('--check')
|
|
7
|
-
const isCompatibleEnabled = args.includes('--compatible')
|
|
8
|
-
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
9
|
-
await pluginsInstall({
|
|
10
|
-
logger,
|
|
11
|
-
isClean,
|
|
12
|
-
isDryRun,
|
|
13
|
-
isCompatibleEnabled,
|
|
14
|
-
plugins
|
|
15
|
-
})
|
|
16
|
-
}
|
|
1
|
+
import { install as pluginsInstall } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function install (logger, ...args) {
|
|
4
|
+
/** strip flags */
|
|
5
|
+
const isClean = args.includes('--clean')
|
|
6
|
+
const isDryRun = args.includes('--dry-run') || args.includes('--check')
|
|
7
|
+
const isCompatibleEnabled = args.includes('--compatible')
|
|
8
|
+
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
9
|
+
await pluginsInstall({
|
|
10
|
+
logger,
|
|
11
|
+
isClean,
|
|
12
|
+
isDryRun,
|
|
13
|
+
isCompatibleEnabled,
|
|
14
|
+
plugins
|
|
15
|
+
})
|
|
16
|
+
}
|
package/lib/commands/ls.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import Project from '../integration/Project.js'
|
|
4
|
+
import { eachOfLimitProgress } from '../util/promises.js'
|
|
5
|
+
|
|
6
|
+
export default async function ls (logger) {
|
|
7
|
+
const project = new Project({ logger })
|
|
8
|
+
const frameworkVersion = project.version
|
|
9
|
+
project.tryThrowInvalidPath()
|
|
10
|
+
const installTargets = (await project.getInstallTargets())
|
|
11
|
+
const installTargetsIndex = installTargets.reduce((hash, p) => {
|
|
12
|
+
const name = (p.name || p.sourcePath)
|
|
13
|
+
hash[name] = p
|
|
14
|
+
return hash
|
|
15
|
+
}, {})
|
|
16
|
+
const installedPlugins = await project.getInstalledPlugins();
|
|
17
|
+
const notInstalled = _.difference(installTargets.map(p => (p.name || p.sourcePath)), installedPlugins.map(p => (p.name || p.sourcePath)))
|
|
18
|
+
const plugins = installedPlugins.concat(notInstalled.map(name => installTargetsIndex[name]))
|
|
19
|
+
await eachOfLimitProgress(
|
|
20
|
+
plugins,
|
|
21
|
+
async (target) => {
|
|
22
|
+
await target.fetchProjectInfo()
|
|
23
|
+
await target.fetchSourceInfo()
|
|
24
|
+
await target.findCompatibleVersion(frameworkVersion)
|
|
25
|
+
},
|
|
26
|
+
percentage => logger?.logProgress?.(`${chalk.bold.cyan('<info>')} Getting plugin info ${percentage}% complete`)
|
|
27
|
+
)
|
|
28
|
+
logger?.log(`${chalk.bold.cyan('<info>')} Getting plugin info 100% complete`)
|
|
29
|
+
plugins
|
|
30
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
31
|
+
.forEach(p => {
|
|
32
|
+
const name = (p.name || p.sourcePath)
|
|
33
|
+
logger?.log(`${chalk.cyan(p.name || p.sourcePath)} ${chalk.green('adapt.json')}: ${installTargetsIndex[name]?.requestedVersion || 'n/a'} ${chalk.green('installed')}: ${p.sourcePath || p.projectVersion || 'n/a'} ${chalk.green('latest')}: ${p.sourcePath || p.latestCompatibleSourceVersion || 'n/a'}`)
|
|
34
|
+
})
|
|
35
|
+
}
|
package/lib/commands/register.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { register as pluginRegister } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function register (logger, ...args) {
|
|
4
|
-
// strip flags
|
|
5
|
-
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
-
return await pluginRegister({
|
|
7
|
-
logger,
|
|
8
|
-
cwd: process.cwd(),
|
|
9
|
-
args
|
|
10
|
-
})
|
|
11
|
-
}
|
|
1
|
+
import { register as pluginRegister } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function register (logger, ...args) {
|
|
4
|
+
// strip flags
|
|
5
|
+
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
+
return await pluginRegister({
|
|
7
|
+
logger,
|
|
8
|
+
cwd: process.cwd(),
|
|
9
|
+
args
|
|
10
|
+
})
|
|
11
|
+
}
|
package/lib/commands/rename.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { rename as pluginRename } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function rename (logger, ...args) {
|
|
4
|
-
/** strip flags */
|
|
5
|
-
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
-
const oldName = args[0]
|
|
7
|
-
const newName = args[1]
|
|
8
|
-
await pluginRename({
|
|
9
|
-
logger,
|
|
10
|
-
cwd: process.cwd(),
|
|
11
|
-
oldName,
|
|
12
|
-
newName
|
|
13
|
-
})
|
|
14
|
-
}
|
|
1
|
+
import { rename as pluginRename } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function rename (logger, ...args) {
|
|
4
|
+
/** strip flags */
|
|
5
|
+
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
+
const oldName = args[0]
|
|
7
|
+
const newName = args[1]
|
|
8
|
+
await pluginRename({
|
|
9
|
+
logger,
|
|
10
|
+
cwd: process.cwd(),
|
|
11
|
+
oldName,
|
|
12
|
+
newName
|
|
13
|
+
})
|
|
14
|
+
}
|
package/lib/commands/search.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { search as pluginsSearch } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function search (logger, ...args) {
|
|
4
|
-
/** strip flags */
|
|
5
|
-
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
-
const searchTerm = (args[0] || '')
|
|
7
|
-
await pluginsSearch({
|
|
8
|
-
logger,
|
|
9
|
-
searchTerm
|
|
10
|
-
})
|
|
11
|
-
}
|
|
1
|
+
import { search as pluginsSearch } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function search (logger, ...args) {
|
|
4
|
+
/** strip flags */
|
|
5
|
+
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
+
const searchTerm = (args[0] || '')
|
|
7
|
+
await pluginsSearch({
|
|
8
|
+
logger,
|
|
9
|
+
searchTerm
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { uninstall as pluginsUninstall } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function uninstall (logger, ...args) {
|
|
4
|
-
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
5
|
-
await pluginsUninstall({
|
|
6
|
-
logger,
|
|
7
|
-
plugins
|
|
8
|
-
})
|
|
9
|
-
}
|
|
1
|
+
import { uninstall as pluginsUninstall } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function uninstall (logger, ...args) {
|
|
4
|
+
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
5
|
+
await pluginsUninstall({
|
|
6
|
+
logger,
|
|
7
|
+
plugins
|
|
8
|
+
})
|
|
9
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { unregister as pluginUnregister } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function register (logger, ...args) {
|
|
4
|
-
// strip flags
|
|
5
|
-
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
-
const pluginName = args[0]
|
|
7
|
-
return await pluginUnregister({
|
|
8
|
-
logger,
|
|
9
|
-
cwd: process.cwd(),
|
|
10
|
-
pluginName
|
|
11
|
-
})
|
|
12
|
-
}
|
|
1
|
+
import { unregister as pluginUnregister } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function register (logger, ...args) {
|
|
4
|
+
// strip flags
|
|
5
|
+
args = args.filter(arg => !String(arg).startsWith('--'))
|
|
6
|
+
const pluginName = args[0]
|
|
7
|
+
return await pluginUnregister({
|
|
8
|
+
logger,
|
|
9
|
+
cwd: process.cwd(),
|
|
10
|
+
pluginName
|
|
11
|
+
})
|
|
12
|
+
}
|
package/lib/commands/update.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { update as pluginsUpdate } from '../integration/PluginManagement.js'
|
|
2
|
-
|
|
3
|
-
export default async function update (logger, ...args) {
|
|
4
|
-
/** strip flags */
|
|
5
|
-
const isDryRun = args.includes('--dry-run') || args.includes('--check')
|
|
6
|
-
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
7
|
-
await pluginsUpdate({
|
|
8
|
-
logger,
|
|
9
|
-
plugins,
|
|
10
|
-
isDryRun
|
|
11
|
-
})
|
|
12
|
-
}
|
|
1
|
+
import { update as pluginsUpdate } from '../integration/PluginManagement.js'
|
|
2
|
+
|
|
3
|
+
export default async function update (logger, ...args) {
|
|
4
|
+
/** strip flags */
|
|
5
|
+
const isDryRun = args.includes('--dry-run') || args.includes('--check')
|
|
6
|
+
const plugins = args.filter(arg => !String(arg).startsWith('--'))
|
|
7
|
+
await pluginsUpdate({
|
|
8
|
+
logger,
|
|
9
|
+
plugins,
|
|
10
|
+
isDryRun
|
|
11
|
+
})
|
|
12
|
+
}
|
package/lib/commands/version.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Project from '../integration/Project.js'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { readValidateJSONSync } from '../util/JSONReadValidate.js'
|
|
4
|
-
import getDirNameFromImportMeta from '../util/getDirNameFromImportMeta.js'
|
|
5
|
-
const __dirname = getDirNameFromImportMeta(import.meta)
|
|
6
|
-
|
|
7
|
-
export default function version (logger) {
|
|
8
|
-
const cliVersionPath = path.join(__dirname, '../../package.json')
|
|
9
|
-
const cliVersion = readValidateJSONSync(cliVersionPath).version
|
|
10
|
-
const project = new Project()
|
|
11
|
-
logger?.log('CLI: ' + cliVersion)
|
|
12
|
-
logger?.log('Framework: ' + project.version)
|
|
13
|
-
}
|
|
1
|
+
import Project from '../integration/Project.js'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { readValidateJSONSync } from '../util/JSONReadValidate.js'
|
|
4
|
+
import getDirNameFromImportMeta from '../util/getDirNameFromImportMeta.js'
|
|
5
|
+
const __dirname = getDirNameFromImportMeta(import.meta)
|
|
6
|
+
|
|
7
|
+
export default function version (logger) {
|
|
8
|
+
const cliVersionPath = path.join(__dirname, '../../package.json')
|
|
9
|
+
const cliVersion = readValidateJSONSync(cliVersionPath).version
|
|
10
|
+
const project = new Project()
|
|
11
|
+
logger?.log('CLI: ' + cliVersion)
|
|
12
|
+
logger?.log('Framework: ' + project.version)
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// guard against ECONNRESET issues https://github.com/adaptlearning/adapt-cli/issues/169
|
|
2
|
+
process.on('uncaughtException', (error, origin) => {
|
|
3
|
+
if (error?.code === 'ECONNRESET') return
|
|
4
|
+
console.error('UNCAUGHT EXCEPTION')
|
|
5
|
+
console.error(error)
|
|
6
|
+
console.error(origin)
|
|
7
|
+
process.exit(1)
|
|
8
|
+
})
|
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { exec } from 'child_process'
|
|
3
|
-
import Project from '../Project.js'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
|
|
6
|
-
export default async function adaptBuild ({
|
|
7
|
-
sourceMaps = false,
|
|
8
|
-
checkJSON = false,
|
|
9
|
-
cache = true,
|
|
10
|
-
outputDir = null,
|
|
11
|
-
cachePath = null,
|
|
12
|
-
cwd = process.cwd(),
|
|
13
|
-
logger
|
|
14
|
-
} = {}) {
|
|
15
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
16
|
-
const project = new Project({ cwd, logger })
|
|
17
|
-
project.tryThrowInvalidPath()
|
|
18
|
-
logger?.log(chalk.cyan('running build'))
|
|
19
|
-
await new Promise((resolve, reject) => {
|
|
20
|
-
const cmd = [
|
|
21
|
-
'npx grunt',
|
|
22
|
-
!checkJSON
|
|
23
|
-
? `server-build:${sourceMaps ? 'dev' : 'prod'}` // AAT
|
|
24
|
-
: `${sourceMaps ? 'diff' : 'build'}`, // Handbuilt
|
|
25
|
-
!cache && '--disable-cache',
|
|
26
|
-
outputDir && `--outputdir=${outputDir}`,
|
|
27
|
-
cachePath && `--cachepath=${cachePath}`
|
|
28
|
-
].filter(Boolean).join(' ');
|
|
29
|
-
exec(cmd, { cwd }, (error, stdout, stderr) => {
|
|
30
|
-
if(error || stderr) {
|
|
31
|
-
const
|
|
32
|
-
e
|
|
33
|
-
e.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { exec } from 'child_process'
|
|
3
|
+
import Project from '../Project.js'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
export default async function adaptBuild ({
|
|
7
|
+
sourceMaps = false,
|
|
8
|
+
checkJSON = false,
|
|
9
|
+
cache = true,
|
|
10
|
+
outputDir = null,
|
|
11
|
+
cachePath = null,
|
|
12
|
+
cwd = process.cwd(),
|
|
13
|
+
logger
|
|
14
|
+
} = {}) {
|
|
15
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
16
|
+
const project = new Project({ cwd, logger })
|
|
17
|
+
project.tryThrowInvalidPath()
|
|
18
|
+
logger?.log(chalk.cyan('running build'))
|
|
19
|
+
await new Promise((resolve, reject) => {
|
|
20
|
+
const cmd = [
|
|
21
|
+
'npx grunt',
|
|
22
|
+
!checkJSON
|
|
23
|
+
? `server-build:${sourceMaps ? 'dev' : 'prod'}` // AAT
|
|
24
|
+
: `${sourceMaps ? 'diff' : 'build'}`, // Handbuilt
|
|
25
|
+
!cache && '--disable-cache',
|
|
26
|
+
outputDir && `--outputdir=${outputDir}`,
|
|
27
|
+
cachePath && `--cachepath=${cachePath}`
|
|
28
|
+
].filter(Boolean).join(' ');
|
|
29
|
+
exec(cmd, { cwd }, (error, stdout, stderr) => {
|
|
30
|
+
if(error || stderr) {
|
|
31
|
+
const matches = stdout.match(/>> Error:\s(.+)\s/);
|
|
32
|
+
const e = new Error('grunt tasks failed')
|
|
33
|
+
e.cmd = cmd;
|
|
34
|
+
e.raw = matches?.[1] ?? stdout;
|
|
35
|
+
e.source = error;
|
|
36
|
+
e.stderr = stderr;
|
|
37
|
+
return reject(e)
|
|
38
|
+
}
|
|
39
|
+
resolve()
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { exec } from 'child_process'
|
|
3
|
-
import { ADAPT_FRAMEWORK } from '../../util/constants.js'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
|
|
6
|
-
export default async function clone ({
|
|
7
|
-
repository = ADAPT_FRAMEWORK,
|
|
8
|
-
branch = 'master',
|
|
9
|
-
cwd = process.cwd(),
|
|
10
|
-
logger
|
|
11
|
-
} = {}) {
|
|
12
|
-
repository = repository.replace(/\.git/g, '')
|
|
13
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
14
|
-
if (!branch && !repository) throw new Error('Repository details are required.')
|
|
15
|
-
logger?.write(chalk.cyan('cloning framework to', cwd, '\t'))
|
|
16
|
-
await new Promise(function (resolve, reject) {
|
|
17
|
-
const child = exec(`git clone ${repository} "${cwd}"`)
|
|
18
|
-
child.addListener('error', reject)
|
|
19
|
-
child.addListener('exit', resolve)
|
|
20
|
-
})
|
|
21
|
-
await new Promise(function (resolve, reject) {
|
|
22
|
-
const child = exec(`git checkout ${branch}`)
|
|
23
|
-
child.addListener('error', reject)
|
|
24
|
-
child.addListener('exit', resolve)
|
|
25
|
-
})
|
|
26
|
-
logger?.log(' ', 'done!')
|
|
27
|
-
}
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { exec } from 'child_process'
|
|
3
|
+
import { ADAPT_FRAMEWORK } from '../../util/constants.js'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
export default async function clone ({
|
|
7
|
+
repository = ADAPT_FRAMEWORK,
|
|
8
|
+
branch = 'master',
|
|
9
|
+
cwd = process.cwd(),
|
|
10
|
+
logger
|
|
11
|
+
} = {}) {
|
|
12
|
+
repository = repository.replace(/\.git/g, '')
|
|
13
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
14
|
+
if (!branch && !repository) throw new Error('Repository details are required.')
|
|
15
|
+
logger?.write(chalk.cyan('cloning framework to', cwd, '\t'))
|
|
16
|
+
await new Promise(function (resolve, reject) {
|
|
17
|
+
const child = exec(`git clone ${repository} "${cwd}"`)
|
|
18
|
+
child.addListener('error', reject)
|
|
19
|
+
child.addListener('exit', resolve)
|
|
20
|
+
})
|
|
21
|
+
await new Promise(function (resolve, reject) {
|
|
22
|
+
const child = exec(`git checkout ${branch}`)
|
|
23
|
+
child.addListener('error', reject)
|
|
24
|
+
child.addListener('exit', resolve)
|
|
25
|
+
})
|
|
26
|
+
logger?.log(' ', 'done!')
|
|
27
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
export default function deleteSrcCore ({
|
|
5
|
-
cwd = process.cwd()
|
|
6
|
-
} = {}) {
|
|
7
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
8
|
-
return fs.rm(path.resolve(cwd, 'src/core'), { recursive: true, force: true })
|
|
9
|
-
}
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
export default function deleteSrcCore ({
|
|
5
|
+
cwd = process.cwd()
|
|
6
|
+
} = {}) {
|
|
7
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
8
|
+
return fs.rm(path.resolve(cwd, 'src/core'), { recursive: true, force: true })
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
export default function deleteSrcCourse ({
|
|
5
|
-
cwd = process.cwd()
|
|
6
|
-
} = {}) {
|
|
7
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
8
|
-
return fs.rm(path.resolve(cwd, 'src/course'), { recursive: true, force: true })
|
|
9
|
-
}
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
export default function deleteSrcCourse ({
|
|
5
|
+
cwd = process.cwd()
|
|
6
|
+
} = {}) {
|
|
7
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
8
|
+
return fs.rm(path.resolve(cwd, 'src/course'), { recursive: true, force: true })
|
|
9
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import downloader from '../../util/download.js'
|
|
2
|
-
import { ADAPT_FRAMEWORK } from '../../util/constants.js'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
|
|
5
|
-
export default async function download ({
|
|
6
|
-
repository = ADAPT_FRAMEWORK,
|
|
7
|
-
branch,
|
|
8
|
-
tmp,
|
|
9
|
-
cwd,
|
|
10
|
-
logger
|
|
11
|
-
} = {}) {
|
|
12
|
-
repository = repository.replace(/\.git/g, '')
|
|
13
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
14
|
-
return downloader({
|
|
15
|
-
repository,
|
|
16
|
-
branch,
|
|
17
|
-
tmp,
|
|
18
|
-
cwd,
|
|
19
|
-
logger
|
|
20
|
-
})
|
|
21
|
-
}
|
|
1
|
+
import downloader from '../../util/download.js'
|
|
2
|
+
import { ADAPT_FRAMEWORK } from '../../util/constants.js'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
export default async function download ({
|
|
6
|
+
repository = ADAPT_FRAMEWORK,
|
|
7
|
+
branch,
|
|
8
|
+
tmp,
|
|
9
|
+
cwd,
|
|
10
|
+
logger
|
|
11
|
+
} = {}) {
|
|
12
|
+
repository = repository.replace(/\.git/g, '')
|
|
13
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
14
|
+
return downloader({
|
|
15
|
+
repository,
|
|
16
|
+
branch,
|
|
17
|
+
tmp,
|
|
18
|
+
cwd,
|
|
19
|
+
logger
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import fs from 'fs-extra'
|
|
3
|
-
import inquirer from 'inquirer'
|
|
4
|
-
import globs from 'globs'
|
|
5
|
-
import path from 'path'
|
|
6
|
-
|
|
7
|
-
export default async function erase ({
|
|
8
|
-
isInteractive = true,
|
|
9
|
-
cwd,
|
|
10
|
-
logger
|
|
11
|
-
} = {}) {
|
|
12
|
-
cwd = path.resolve(process.cwd(), cwd)
|
|
13
|
-
if (!fs.existsSync(cwd)) return
|
|
14
|
-
if (isInteractive) {
|
|
15
|
-
const results = await inquirer.prompt([{
|
|
16
|
-
name: 'overwrite existing course?',
|
|
17
|
-
type: 'confirm',
|
|
18
|
-
default: false
|
|
19
|
-
}])
|
|
20
|
-
if (!results['overwrite existing course?']) {
|
|
21
|
-
throw new Error('Course already exists and cannot overwrite.')
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
logger?.log(chalk.cyan('deleting existing course'))
|
|
25
|
-
const files = await new Promise((resolve, reject) => {
|
|
26
|
-
globs('**', { cwd }, (err, files) => {
|
|
27
|
-
if (err) return reject(err)
|
|
28
|
-
resolve(files)
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
for (const file of files) {
|
|
32
|
-
await fs.rm(file, { recursive: true })
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import inquirer from 'inquirer'
|
|
4
|
+
import globs from 'globs'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
export default async function erase ({
|
|
8
|
+
isInteractive = true,
|
|
9
|
+
cwd,
|
|
10
|
+
logger
|
|
11
|
+
} = {}) {
|
|
12
|
+
cwd = path.resolve(process.cwd(), cwd)
|
|
13
|
+
if (!fs.existsSync(cwd)) return
|
|
14
|
+
if (isInteractive) {
|
|
15
|
+
const results = await inquirer.prompt([{
|
|
16
|
+
name: 'overwrite existing course?',
|
|
17
|
+
type: 'confirm',
|
|
18
|
+
default: false
|
|
19
|
+
}])
|
|
20
|
+
if (!results['overwrite existing course?']) {
|
|
21
|
+
throw new Error('Course already exists and cannot overwrite.')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
logger?.log(chalk.cyan('deleting existing course'))
|
|
25
|
+
const files = await new Promise((resolve, reject) => {
|
|
26
|
+
globs('**', { cwd }, (err, files) => {
|
|
27
|
+
if (err) return reject(err)
|
|
28
|
+
resolve(files)
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
await fs.rm(file, { recursive: true })
|
|
33
|
+
}
|
|
34
|
+
}
|