contensis-cli 1.0.0-beta.95 → 1.0.0-beta.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/dev.js +2 -6
- package/dist/commands/dev.js.map +2 -2
- package/dist/commands/import.js +18 -0
- package/dist/commands/import.js.map +2 -2
- package/dist/localisation/en-GB.js +28 -11
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/DevInit-to-CIWorkflow.js +251 -136
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +3 -3
- package/dist/models/DevService.d.js.map +1 -1
- package/dist/services/ContensisCliService.js +64 -0
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/services/ContensisDevService.js +65 -18
- package/dist/services/ContensisDevService.js.map +2 -2
- package/dist/services/ContensisRoleService.js +31 -4
- package/dist/services/ContensisRoleService.js.map +3 -3
- package/dist/util/diff.js +3 -1
- package/dist/util/diff.js.map +2 -2
- package/dist/util/git.js +4 -2
- package/dist/util/git.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -1
- package/src/commands/dev.ts +7 -7
- package/src/commands/import.ts +25 -0
- package/src/localisation/en-GB.ts +43 -9
- package/src/mappers/DevInit-to-CIWorkflow.ts +386 -196
- package/src/models/DevService.d.ts +14 -0
- package/src/services/ContensisCliService.ts +84 -0
- package/src/services/ContensisDevService.ts +80 -21
- package/src/services/ContensisRoleService.ts +33 -1
- package/src/util/diff.ts +4 -1
- package/src/util/git.ts +4 -3
- package/src/version.ts +1 -1
|
@@ -44,7 +44,9 @@ var import_git = require("../util/git");
|
|
|
44
44
|
var import_json = require("../util/json.formatter");
|
|
45
45
|
var import_os = require("../util/os");
|
|
46
46
|
var import_yaml = require("../util/yaml");
|
|
47
|
+
var import_nanospinner = require("nanospinner");
|
|
47
48
|
class ContensisDev extends import_ContensisRoleService.default {
|
|
49
|
+
git;
|
|
48
50
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
49
51
|
super(args, outputOpts, contensisOpts);
|
|
50
52
|
}
|
|
@@ -62,7 +64,7 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
62
64
|
const apiKeyExists = (findKey) => apiKeys == null ? void 0 : apiKeys.find(
|
|
63
65
|
(k) => k.name.trim().toLowerCase() === (findKey == null ? void 0 : findKey.trim().toLowerCase())
|
|
64
66
|
);
|
|
65
|
-
const git = new import_git.GitHelper(projectHome);
|
|
67
|
+
const git = this.git = new import_git.GitHelper(projectHome);
|
|
66
68
|
const workflowFiles = git.workflows;
|
|
67
69
|
let ciFileName = git.ciFileName;
|
|
68
70
|
const devKeyName = `${git.name} development`;
|
|
@@ -112,8 +114,31 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
112
114
|
git.ciFileName = ciFileName;
|
|
113
115
|
}
|
|
114
116
|
log.raw(log.infoText(messages.devinit.ciDetails(ciFileName)));
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
let mappedWorkflow;
|
|
118
|
+
const { clientDetailsOption } = await import_inquirer.default.prompt({
|
|
119
|
+
name: "clientDetailsOption",
|
|
120
|
+
type: "list",
|
|
121
|
+
prefix: "\u{1F511}",
|
|
122
|
+
message: messages.devinit.clientDetailsLocation(),
|
|
123
|
+
choices: [
|
|
124
|
+
messages.devinit.clientDetailsInGit(git),
|
|
125
|
+
messages.devinit.clientDetailsInEnv()
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
if (clientDetailsOption === messages.devinit.clientDetailsInEnv()) {
|
|
129
|
+
this.clientDetailsLocation = "env";
|
|
130
|
+
} else {
|
|
131
|
+
this.clientDetailsLocation = "git";
|
|
132
|
+
}
|
|
133
|
+
if (this.clientDetailsLocation === "env") {
|
|
134
|
+
mappedWorkflow = await (0, import_DevInit_to_CIWorkflow.mapCIWorkflowContent)(this);
|
|
135
|
+
this.clientId = existingDeployKey == null ? void 0 : existingDeployKey.id;
|
|
136
|
+
this.clientSecret = existingDeployKey == null ? void 0 : existingDeployKey.sharedSecret;
|
|
137
|
+
log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));
|
|
138
|
+
} else {
|
|
139
|
+
mappedWorkflow = await (0, import_DevInit_to_CIWorkflow.mapCIWorkflowContent)(this);
|
|
140
|
+
log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));
|
|
141
|
+
}
|
|
117
142
|
if (!dryRun) {
|
|
118
143
|
const { confirm } = await import_inquirer.default.prompt([
|
|
119
144
|
{
|
|
@@ -127,15 +152,32 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
127
152
|
if (!confirm)
|
|
128
153
|
return;
|
|
129
154
|
}
|
|
130
|
-
|
|
155
|
+
let accessToken = void 0;
|
|
156
|
+
const { canContinue } = await import_inquirer.default.prompt([
|
|
131
157
|
{
|
|
132
|
-
type: "
|
|
158
|
+
type: "confirm",
|
|
133
159
|
prefix: "\u{1F6E1}\uFE0F",
|
|
134
160
|
message: messages.devinit.accessTokenPrompt(),
|
|
135
|
-
name: "
|
|
161
|
+
name: "canContinue"
|
|
136
162
|
}
|
|
137
163
|
]);
|
|
138
164
|
log.raw("");
|
|
165
|
+
if (!canContinue)
|
|
166
|
+
return;
|
|
167
|
+
if (canContinue) {
|
|
168
|
+
const spinner = (0, import_nanospinner.createSpinner)(messages.devinit.accessTokenFetch());
|
|
169
|
+
spinner.start();
|
|
170
|
+
const token = await this.GetDeliveryApiKey();
|
|
171
|
+
if (token) {
|
|
172
|
+
spinner.success();
|
|
173
|
+
this.log.success(messages.devinit.accessTokenSuccess(token));
|
|
174
|
+
accessToken = token;
|
|
175
|
+
} else {
|
|
176
|
+
spinner.error();
|
|
177
|
+
this.log.error(messages.devinit.accessTokenFailed());
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
139
181
|
const checkpoint = (op) => {
|
|
140
182
|
if (errors.length)
|
|
141
183
|
throw errors[0];
|
|
@@ -188,16 +230,19 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
188
230
|
};
|
|
189
231
|
if (accessToken)
|
|
190
232
|
envContentsToAdd["ACCESS_TOKEN"] = accessToken;
|
|
233
|
+
if (this.clientDetailsLocation === "env") {
|
|
234
|
+
if (git.type === "github") {
|
|
235
|
+
envContentsToAdd["CONTENSIS_CLIENT_ID"] = this.clientId;
|
|
236
|
+
envContentsToAdd["CONTENSIS_CLIENT_SECRET"] = this.clientSecret;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
191
239
|
const envFilePath = `${projectHome}/.env`;
|
|
192
240
|
const existingEnvFile = (0, import_file_provider.readFile)(envFilePath);
|
|
193
241
|
const envFileLines = (0, import_dotenv.mergeDotEnvFileContents)(
|
|
194
242
|
(existingEnvFile || "").split("\n").filter((l) => !!l),
|
|
195
243
|
envContentsToAdd
|
|
196
244
|
);
|
|
197
|
-
const newEnvFileContent = (
|
|
198
|
-
`${envFileLines.join("\n")}
|
|
199
|
-
`
|
|
200
|
-
);
|
|
245
|
+
const newEnvFileContent = envFileLines.join("\n");
|
|
201
246
|
const envDiff = (0, import_diff.diffFileContent)(existingEnvFile || "", newEnvFileContent);
|
|
202
247
|
if (dryRun) {
|
|
203
248
|
if (envDiff) {
|
|
@@ -236,14 +281,16 @@ ${mappedWorkflow.diff}`
|
|
|
236
281
|
checkpoint("CI file updated");
|
|
237
282
|
}
|
|
238
283
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
284
|
+
if (this.clientDetailsLocation === "git") {
|
|
285
|
+
log.warning(messages.devinit.addGitSecretsIntro());
|
|
286
|
+
log.help(
|
|
287
|
+
messages.devinit.addGitSecretsHelp(
|
|
288
|
+
git,
|
|
289
|
+
existingDeployKey == null ? void 0 : existingDeployKey.id,
|
|
290
|
+
existingDeployKey == null ? void 0 : existingDeployKey.sharedSecret
|
|
291
|
+
)
|
|
292
|
+
);
|
|
293
|
+
}
|
|
247
294
|
if (dryRun) {
|
|
248
295
|
log.success(messages.devinit.dryRun());
|
|
249
296
|
log.help(messages.devinit.noChanges());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/ContensisDevService.ts"],
|
|
4
|
-
"sourcesContent": ["import to from 'await-to-js';\nimport { execFile, spawn } from 'child_process';\nimport inquirer from 'inquirer';\nimport path from 'path';\n\nimport { Role } from 'contensis-management-api/lib/models';\nimport { MigrateRequest } from 'migratortron';\n\nimport ContensisRole from './ContensisRoleService';\nimport { OutputOptionsConstructorArg } from '~/models/CliService';\nimport { EnvContentsToAdd } from '~/models/DevService';\nimport { mapSiteConfigYaml } from '~/mappers/DevRequests-to-RequestHanderSiteConfigYaml';\nimport { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';\nimport {\n deployKeyRole,\n devKeyRole,\n} from '~/mappers/DevInit-to-RolePermissions';\nimport { appRootDir, readFile, writeFile } from '~/providers/file-provider';\nimport { diffFileContent } from '~/util/diff';\nimport { mergeDotEnvFileContents } from '~/util/dotenv';\nimport { findByIdOrName } from '~/util/find';\nimport { GitHelper } from '~/util/git';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { normaliseLineEndings, winSlash } from '~/util/os';\nimport { stringifyYaml } from '~/util/yaml';\n\nclass ContensisDev extends ContensisRole {\n constructor(\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n super(args, outputOpts, contensisOpts);\n }\n\n DevelopmentInit = async (projectHome: string, opts: any) => {\n const { dryRun = false } = opts || {};\n const { currentEnv, currentProject, log, messages } = this;\n const contensis = await this.ConnectContensis();\n\n if (contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n return;\n }\n const apiKeyExists = (findKey: string) =>\n apiKeys?.find(\n k => k.name.trim().toLowerCase() === findKey?.trim().toLowerCase()\n );\n\n // Retrieve git info\n const git = new GitHelper(projectHome);\n\n // Retrieve ci workflow info\n const workflowFiles = git.workflows;\n\n // Set variables for performing operations and logging etc.\n let ciFileName = git.ciFileName;\n\n const devKeyName = `${git.name} development`;\n const devKeyDescription = `${git.name} [contensis-cli]`;\n let existingDevKey = apiKeyExists(devKeyName);\n\n const deployKeyName = `${git.name} deployment`;\n const deployKeyDescription = `${git.name} deploy [contensis-cli]`;\n\n let existingDeployKey = apiKeyExists(deployKeyName);\n\n const blockId = git.name;\n const errors = [] as AppError[];\n\n // Start render console output\n log.raw('');\n log.success(messages.devinit.intro());\n log.raw('');\n log.raw(\n log.infoText(\n messages.devinit.projectDetails(\n git.name,\n currentEnv,\n currentProject,\n git\n )\n )\n );\n log.raw(\n log.infoText(\n messages.devinit.developmentKey(devKeyName, !!existingDevKey)\n )\n );\n log.raw(\n log.infoText(\n messages.devinit.deploymentKey(deployKeyName, !!existingDeployKey)\n )\n );\n log.raw('');\n\n if (Array.isArray(workflowFiles) && workflowFiles.length > 1) {\n // Choose GitHub workflow file (if multiple)\n ({ ciFileName } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u29F0',\n message: messages.devinit.ciMultipleChoices(),\n name: 'ciFileName',\n choices: workflowFiles,\n default: workflowFiles.find(f => f.includes('docker')),\n },\n ]));\n log.raw('');\n git.ciFileName = ciFileName;\n }\n\n log.raw(log.infoText(messages.devinit.ciDetails(ciFileName)));\n\n // Look at the workflow file content and make updates\n const mappedWorkflow = await mapCIWorkflowContent(this, git);\n\n log.help(messages.devinit.ciIntro(git));\n\n if (!dryRun) {\n // Confirm prompt\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n message: messages.devinit.confirm(),\n name: 'confirm',\n default: false,\n },\n ]);\n log.raw('');\n if (!confirm) return;\n }\n\n // Access token prompt\n const { accessToken }: { accessToken: string } = await inquirer.prompt([\n {\n type: 'input',\n prefix: '\uD83D\uDEE1\uFE0F',\n message: messages.devinit.accessTokenPrompt(),\n name: 'accessToken',\n },\n ]);\n log.raw('');\n\n // Magic happens...\n const checkpoint = (op: string) => {\n if (errors.length) throw errors[0];\n else log.debug(`${op} completed ok`);\n return true;\n };\n\n // Arrange API keys for development and deployment\n const [getRolesErr, roles] = await to(contensis.roles.GetRoles());\n if (!roles && getRolesErr) errors.push(getRolesErr);\n checkpoint(`fetched ${roles?.length} roles`);\n if (dryRun) {\n checkpoint(`skip api key creation (dry-run)`);\n } else {\n existingDevKey = await this.CreateOrUpdateApiKey(\n existingDevKey,\n devKeyName,\n devKeyDescription\n );\n checkpoint('dev key created');\n\n existingDeployKey = await this.CreateOrUpdateApiKey(\n existingDeployKey,\n deployKeyName,\n deployKeyDescription\n );\n checkpoint('deploy key created');\n\n // Ensure dev API key is assigned to a role\n let existingDevRole = findByIdOrName(roles || [], devKeyName, true) as\n | Role\n | undefined;\n existingDevRole = await this.CreateOrUpdateRole(\n existingDevRole,\n devKeyRole(devKeyName, devKeyDescription)\n );\n checkpoint('dev key role assigned');\n log.success(messages.devinit.createDevKey(devKeyName, true));\n\n // Ensure deploy API key is assigned to a role with the right permissions\n let existingDeployRole = findByIdOrName(\n roles || [],\n deployKeyName,\n true\n ) as Role | undefined;\n existingDeployRole = await this.CreateOrUpdateRole(\n existingDeployRole,\n deployKeyRole(deployKeyName, deployKeyDescription)\n );\n\n checkpoint('deploy key role assigned');\n log.success(messages.devinit.createDeployKey(deployKeyName, true));\n checkpoint('api keys done');\n }\n\n // Update or create a file called .env in project home\n const envContentsToAdd: EnvContentsToAdd = {\n ALIAS: currentEnv,\n PROJECT: currentProject,\n };\n if (accessToken) envContentsToAdd['ACCESS_TOKEN'] = accessToken;\n\n const envFilePath = `${projectHome}/.env`;\n const existingEnvFile = readFile(envFilePath);\n const envFileLines = mergeDotEnvFileContents(\n (existingEnvFile || '').split('\\n').filter(l => !!l),\n envContentsToAdd\n );\n const newEnvFileContent = normaliseLineEndings(\n `${envFileLines.join('\\n')}\\n`\n );\n const envDiff = diffFileContent(existingEnvFile || '', newEnvFileContent);\n\n if (dryRun) {\n if (envDiff) {\n log.info(`Updating .env file ${winSlash(envFilePath)}:\\n${envDiff}`);\n log.raw('');\n }\n checkpoint('skip .env file update (dry-run)');\n } else {\n if (envDiff) log.info(`updating .env file ${winSlash(envFilePath)}`);\n writeFile(envFilePath, envFileLines.join('\\n'));\n checkpoint('.env file updated');\n log.success(messages.devinit.writeEnvFile());\n // log.help(messages.devinit.useEnvFileTip());\n }\n\n // Update CI file -- different for GH/GL\n if (mappedWorkflow?.diff) {\n log.info(\n `Updating ${winSlash(ciFileName)} file:\\n${mappedWorkflow.diff}`\n );\n log.raw('');\n }\n if (dryRun) {\n checkpoint('skip CI file update (dry-run)');\n //log.object(ciFileLines);\n } else {\n if (mappedWorkflow?.newWorkflow) {\n if (mappedWorkflow?.diff) {\n writeFile(git.ciFilePath, mappedWorkflow.newWorkflow);\n log.success(messages.devinit.writeCiFile(`./${ciFileName}`));\n log.info(\n messages.devinit.ciBlockTip(blockId, currentEnv, currentProject)\n );\n } else {\n log.info(messages.devinit.ciFileNoChanges(`./${ciFileName}`));\n }\n checkpoint('CI file updated');\n }\n }\n\n // Echo Deployment API key to console, ask user to add secrets to repo\n log.warning(messages.devinit.addGitSecretsIntro());\n log.help(\n messages.devinit.addGitSecretsHelp(\n git,\n existingDeployKey?.id,\n existingDeployKey?.sharedSecret\n )\n );\n\n if (dryRun) {\n log.success(messages.devinit.dryRun());\n log.help(messages.devinit.noChanges());\n } else {\n log.success(messages.devinit.success());\n log.help(messages.devinit.startProjectTip());\n }\n }\n };\n\n ExecRequestHandler = async (blockIds: string[], overrideArgs?: string[]) => {\n // if no request handler exe\n // download it.\n\n // if update arg, redownload it\n\n const { log } = this;\n // const getPrefixOld = log.getPrefix;\n const exeHome = path.join(appRootDir, 'reqhan');\n const exe = 'Zengenti.Contensis.RequestHandler.LocalDevelopment';\n const exePath = path.join(exeHome, exe);\n const siteConfigPath = path.join(appRootDir, 'site_config.yaml');\n\n const siteConfig = await mapSiteConfigYaml(this);\n writeFile('site_config.yaml', stringifyYaml(siteConfig));\n\n const args = overrideArgs\n ? typeof overrideArgs?.[0] === 'string' &&\n overrideArgs[0].includes(' ', 2)\n ? overrideArgs[0].split(' ')\n : overrideArgs\n : []; // args could be [ '-c .\\\\site_config.yaml' ] or [ '-c', '.\\\\site_config.yaml' ]\n\n // Add required args\n if (!args.find(a => a === '-c')) args.push('-c', siteConfigPath);\n\n // const child = execFile(exePath, args);\n\n const child = spawn(exePath, args, { stdio: 'inherit' });\n\n // log.raw('');\n log.info(`Launching request handler...`);\n if (overrideArgs?.length)\n this.log.warning(\n `Spawning process with supplied args: ${JSON.stringify(\n child.spawnargs,\n null,\n 2\n )}`\n );\n\n let isRunning = false;\n\n // Log child output through event listeners\n child?.stdout?.on('data', data => {\n isRunning = true;\n log.raw(data);\n });\n\n child?.stderr?.on('data', data => {\n log.error(data);\n });\n\n child.on('spawn', () => {\n isRunning = true;\n log.help(\n `You may see a firewall popup requesting network access, it is safe to approve`\n );\n // log.getPrefix = () => Logger.infoText(`[rqh]`);\n });\n\n child.on('exit', code => {\n isRunning = false;\n\n log[code === 0 ? 'success' : 'warning'](\n `Request handler exited with code ${code}\\n`\n );\n });\n\n child.on('error', error => {\n isRunning = false;\n log.error(`Could not launch request handler due to error \\n${error}`);\n });\n\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n // keep the method running until we can return\n while (true === true) {\n if (!isRunning) {\n // log.getPrefix = getPrefixOld; // restore logger state\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n };\n}\nexport const devCommand = (\n commandArgs: string[],\n outputOpts: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisDev(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\n\nexport default ContensisDev;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAe;AACf,
|
|
4
|
+
"sourcesContent": ["import to from 'await-to-js';\nimport { spawn } from 'child_process';\nimport inquirer from 'inquirer';\nimport path from 'path';\n\nimport { Role } from 'contensis-management-api/lib/models';\nimport { MigrateRequest } from 'migratortron';\n\nimport ContensisRole from './ContensisRoleService';\nimport { OutputOptionsConstructorArg } from '~/models/CliService';\nimport { EnvContentsToAdd } from '~/models/DevService';\nimport { mapSiteConfigYaml } from '~/mappers/DevRequests-to-RequestHanderSiteConfigYaml';\nimport { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';\nimport {\n deployKeyRole,\n devKeyRole,\n} from '~/mappers/DevInit-to-RolePermissions';\nimport { appRootDir, readFile, writeFile } from '~/providers/file-provider';\nimport { diffFileContent } from '~/util/diff';\nimport { mergeDotEnvFileContents } from '~/util/dotenv';\nimport { findByIdOrName } from '~/util/find';\nimport { GitHelper } from '~/util/git';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { winSlash } from '~/util/os';\nimport { stringifyYaml } from '~/util/yaml';\nimport { createSpinner } from 'nanospinner';\n\nclass ContensisDev extends ContensisRole {\n git!: GitHelper;\n\n constructor(\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n super(args, outputOpts, contensisOpts);\n }\n\n DevelopmentInit = async (projectHome: string, opts: any) => {\n const { dryRun = false } = opts || {};\n const { currentEnv, currentProject, log, messages } = this;\n const contensis = await this.ConnectContensis();\n\n if (contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n return;\n }\n const apiKeyExists = (findKey: string) =>\n apiKeys?.find(\n k => k.name.trim().toLowerCase() === findKey?.trim().toLowerCase()\n );\n\n // Retrieve git info\n const git = (this.git = new GitHelper(projectHome));\n\n // Retrieve ci workflow info\n const workflowFiles = git.workflows;\n\n // Set variables for performing operations and logging etc.\n let ciFileName = git.ciFileName;\n\n const devKeyName = `${git.name} development`;\n const devKeyDescription = `${git.name} [contensis-cli]`;\n let existingDevKey = apiKeyExists(devKeyName);\n\n const deployKeyName = `${git.name} deployment`;\n const deployKeyDescription = `${git.name} deploy [contensis-cli]`;\n\n let existingDeployKey = apiKeyExists(deployKeyName);\n\n const blockId = git.name;\n const errors = [] as AppError[];\n\n // Start render console output\n log.raw('');\n log.success(messages.devinit.intro());\n log.raw('');\n log.raw(\n log.infoText(\n messages.devinit.projectDetails(\n git.name,\n currentEnv,\n currentProject,\n git\n )\n )\n );\n log.raw(\n log.infoText(\n messages.devinit.developmentKey(devKeyName, !!existingDevKey)\n )\n );\n log.raw(\n log.infoText(\n messages.devinit.deploymentKey(deployKeyName, !!existingDeployKey)\n )\n );\n log.raw('');\n\n if (Array.isArray(workflowFiles) && workflowFiles.length > 1) {\n // Choose GitHub workflow file (if multiple)\n ({ ciFileName } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u29F0',\n message: messages.devinit.ciMultipleChoices(),\n name: 'ciFileName',\n choices: workflowFiles,\n default: workflowFiles.find(f => f.includes('docker')),\n },\n ]));\n log.raw('');\n git.ciFileName = ciFileName;\n }\n\n log.raw(log.infoText(messages.devinit.ciDetails(ciFileName)));\n\n let mappedWorkflow;\n // Location for Client ID / Secret.\n const { clientDetailsOption } = await inquirer.prompt({\n name: 'clientDetailsOption',\n type: 'list',\n prefix: '\uD83D\uDD11',\n // Where would you like to store your Client ID/Secret?\n message: messages.devinit.clientDetailsLocation(),\n choices: [\n messages.devinit.clientDetailsInGit(git),\n messages.devinit.clientDetailsInEnv(),\n ],\n });\n\n // global 'clientDetailsLocation' variable stores users input on where client id / secert are stored\n if (clientDetailsOption === messages.devinit.clientDetailsInEnv()) {\n this.clientDetailsLocation = 'env';\n } else {\n this.clientDetailsLocation = 'git';\n }\n\n if (this.clientDetailsLocation === 'env') {\n // Update CI Workflow to pull from ENV variables\n mappedWorkflow = await mapCIWorkflowContent(this);\n // Add client id and secret to global 'this'\n this.clientId = existingDeployKey?.id;\n this.clientSecret = existingDeployKey?.sharedSecret;\n log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));\n } else {\n // Look at the workflow file content and make updates\n mappedWorkflow = await mapCIWorkflowContent(this);\n log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));\n }\n\n if (!dryRun) {\n // Confirm prompt\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n message: messages.devinit.confirm(),\n name: 'confirm',\n default: false,\n },\n ]);\n log.raw('');\n if (!confirm) return;\n }\n\n // Access token prompt\n let accessToken: string | undefined = undefined;\n const { canContinue } = await inquirer.prompt([\n {\n type: 'confirm',\n prefix: '\uD83D\uDEE1\uFE0F',\n // We're all set to grab your access token. Can we proceed? (\u23CE continue)\n message: messages.devinit.accessTokenPrompt(),\n name: 'canContinue',\n },\n ]);\n log.raw('');\n\n if (!canContinue) return;\n if (canContinue) {\n const spinner = createSpinner(messages.devinit.accessTokenFetch());\n spinner.start();\n\n // Fetching access token\n const token = await this.GetDeliveryApiKey();\n\n if (token) {\n spinner.success();\n this.log.success(messages.devinit.accessTokenSuccess(token));\n accessToken = token;\n } else {\n spinner.error();\n this.log.error(messages.devinit.accessTokenFailed());\n return;\n }\n }\n\n // Magic happens...\n const checkpoint = (op: string) => {\n if (errors.length) throw errors[0];\n else log.debug(`${op} completed ok`);\n return true;\n };\n\n // Arrange API keys for development and deployment\n const [getRolesErr, roles] = await to(contensis.roles.GetRoles());\n if (!roles && getRolesErr) errors.push(getRolesErr);\n checkpoint(`fetched ${roles?.length} roles`);\n if (dryRun) {\n checkpoint(`skip api key creation (dry-run)`);\n } else {\n existingDevKey = await this.CreateOrUpdateApiKey(\n existingDevKey,\n devKeyName,\n devKeyDescription\n );\n checkpoint('dev key created');\n\n existingDeployKey = await this.CreateOrUpdateApiKey(\n existingDeployKey,\n deployKeyName,\n deployKeyDescription\n );\n checkpoint('deploy key created');\n\n // Ensure dev API key is assigned to a role\n let existingDevRole = findByIdOrName(roles || [], devKeyName, true) as\n | Role\n | undefined;\n existingDevRole = await this.CreateOrUpdateRole(\n existingDevRole,\n devKeyRole(devKeyName, devKeyDescription)\n );\n checkpoint('dev key role assigned');\n log.success(messages.devinit.createDevKey(devKeyName, true));\n\n // Ensure deploy API key is assigned to a role with the right permissions\n let existingDeployRole = findByIdOrName(\n roles || [],\n deployKeyName,\n true\n ) as Role | undefined;\n existingDeployRole = await this.CreateOrUpdateRole(\n existingDeployRole,\n deployKeyRole(deployKeyName, deployKeyDescription)\n );\n\n checkpoint('deploy key role assigned');\n log.success(messages.devinit.createDeployKey(deployKeyName, true));\n checkpoint('api keys done');\n }\n\n // Update or create a file called .env in project home\n const envContentsToAdd: EnvContentsToAdd = {\n ALIAS: currentEnv,\n PROJECT: currentProject,\n };\n if (accessToken) envContentsToAdd['ACCESS_TOKEN'] = accessToken;\n if (this.clientDetailsLocation === 'env') {\n if (git.type === 'github') {\n envContentsToAdd['CONTENSIS_CLIENT_ID'] = this.clientId;\n envContentsToAdd['CONTENSIS_CLIENT_SECRET'] = this.clientSecret;\n }\n }\n\n const envFilePath = `${projectHome}/.env`;\n const existingEnvFile = readFile(envFilePath);\n const envFileLines = mergeDotEnvFileContents(\n (existingEnvFile || '').split('\\n').filter(l => !!l),\n envContentsToAdd\n );\n const newEnvFileContent = envFileLines.join('\\n');\n const envDiff = diffFileContent(existingEnvFile || '', newEnvFileContent);\n\n if (dryRun) {\n if (envDiff) {\n log.info(`Updating .env file ${winSlash(envFilePath)}:\\n${envDiff}`);\n log.raw('');\n }\n checkpoint('skip .env file update (dry-run)');\n } else {\n if (envDiff) log.info(`updating .env file ${winSlash(envFilePath)}`);\n writeFile(envFilePath, envFileLines.join('\\n'));\n checkpoint('.env file updated');\n log.success(messages.devinit.writeEnvFile());\n // log.help(messages.devinit.useEnvFileTip());\n }\n\n // Update CI file -- different for GH/GL\n if (mappedWorkflow?.diff) {\n log.info(\n `Updating ${winSlash(ciFileName)} file:\\n${mappedWorkflow.diff}`\n );\n log.raw('');\n }\n if (dryRun) {\n checkpoint('skip CI file update (dry-run)');\n //log.object(ciFileLines);\n } else {\n if (mappedWorkflow?.newWorkflow) {\n if (mappedWorkflow?.diff) {\n writeFile(git.ciFilePath, mappedWorkflow.newWorkflow);\n log.success(messages.devinit.writeCiFile(`./${ciFileName}`));\n log.info(\n messages.devinit.ciBlockTip(blockId, currentEnv, currentProject)\n );\n } else {\n log.info(messages.devinit.ciFileNoChanges(`./${ciFileName}`));\n }\n checkpoint('CI file updated');\n }\n }\n\n if (this.clientDetailsLocation === 'git') {\n // Echo Deployment API key to console, ask user to add secrets to repo\n log.warning(messages.devinit.addGitSecretsIntro());\n log.help(\n messages.devinit.addGitSecretsHelp(\n git,\n existingDeployKey?.id,\n existingDeployKey?.sharedSecret\n )\n );\n }\n\n if (dryRun) {\n log.success(messages.devinit.dryRun());\n log.help(messages.devinit.noChanges());\n } else {\n log.success(messages.devinit.success());\n log.help(messages.devinit.startProjectTip());\n }\n }\n };\n\n ExecRequestHandler = async (blockIds: string[], overrideArgs?: string[]) => {\n // if no request handler exe\n // download it.\n\n // if update arg, redownload it\n\n const { log } = this;\n // const getPrefixOld = log.getPrefix;\n const exeHome = path.join(appRootDir, 'reqhan');\n const exe = 'Zengenti.Contensis.RequestHandler.LocalDevelopment';\n const exePath = path.join(exeHome, exe);\n const siteConfigPath = path.join(appRootDir, 'site_config.yaml');\n\n const siteConfig = await mapSiteConfigYaml(this);\n writeFile('site_config.yaml', stringifyYaml(siteConfig));\n\n const args = overrideArgs\n ? typeof overrideArgs?.[0] === 'string' &&\n overrideArgs[0].includes(' ', 2)\n ? overrideArgs[0].split(' ')\n : overrideArgs\n : []; // args could be [ '-c .\\\\site_config.yaml' ] or [ '-c', '.\\\\site_config.yaml' ]\n\n // Add required args\n if (!args.find(a => a === '-c')) args.push('-c', siteConfigPath);\n\n // const child = execFile(exePath, args);\n\n const child = spawn(exePath, args, { stdio: 'inherit' });\n\n // log.raw('');\n log.info(`Launching request handler...`);\n if (overrideArgs?.length)\n this.log.warning(\n `Spawning process with supplied args: ${JSON.stringify(\n child.spawnargs,\n null,\n 2\n )}`\n );\n\n let isRunning = false;\n\n // Log child output through event listeners\n child?.stdout?.on('data', data => {\n isRunning = true;\n log.raw(data);\n });\n\n child?.stderr?.on('data', data => {\n log.error(data);\n });\n\n child.on('spawn', () => {\n isRunning = true;\n log.help(\n `You may see a firewall popup requesting network access, it is safe to approve`\n );\n // log.getPrefix = () => Logger.infoText(`[rqh]`);\n });\n\n child.on('exit', code => {\n isRunning = false;\n\n log[code === 0 ? 'success' : 'warning'](\n `Request handler exited with code ${code}\\n`\n );\n });\n\n child.on('error', error => {\n isRunning = false;\n log.error(`Could not launch request handler due to error \\n${error}`);\n });\n\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n // keep the method running until we can return\n while (true === true) {\n if (!isRunning) {\n // log.getPrefix = getPrefixOld; // restore logger state\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n };\n}\nexport const devCommand = (\n commandArgs: string[],\n outputOpts: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisDev(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\n\nexport default ContensisDev;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAe;AACf,2BAAsB;AACtB,sBAAqB;AACrB,kBAAiB;AAKjB,kCAA0B;AAG1B,wDAAkC;AAClC,mCAAqC;AACrC,wCAGO;AACP,2BAAgD;AAChD,kBAAgC;AAChC,oBAAwC;AACxC,kBAA+B;AAC/B,iBAA0B;AAC1B,kBAA8B;AAC9B,gBAAyB;AACzB,kBAA8B;AAC9B,yBAA8B;AAE9B,MAAM,qBAAqB,4BAAAA,QAAc;AAAA,EACvC;AAAA,EAEA,YACE,MACA,YAC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AACvB,kBAAY;AAEZ,UAAI,SAAS,IAAI,YAAY;AAAA,QAC3B,oCAAoC;AAAA;AAAA,MACtC;AAAA,IACF,CAAC;AAED,UAAM,GAAG,SAAS,WAAS;AACzB,kBAAY;AACZ,UAAI,MAAM;AAAA,EAAmD,OAAO;AAAA,IACtE,CAAC;AAED,UAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,GAAI,CAAC;AAGtD,WAAO,MAAe;AACpB,UAAI,CAAC,WAAW;AAEd;AAAA,MACF;AACA,YAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,GAAI,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AACO,MAAM,aAAa,CACxB,aACA,YACA,gBAAyC,CAAC,MACvC;AACH,SAAO,IAAI,aAAa,CAAC,IAAI,IAAI,GAAG,WAAW,GAAG,YAAY,aAAa;AAC7E;AAEA,IAAO,8BAAQ;",
|
|
6
6
|
"names": ["ContensisRole", "inquirer", "to", "path"]
|
|
7
7
|
}
|
|
@@ -9,13 +9,13 @@ var __export = (target, all) => {
|
|
|
9
9
|
for (var name in all)
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var __copyProps = (
|
|
12
|
+
var __copyProps = (to2, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
14
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
15
|
+
if (!__hasOwnProp.call(to2, key) && key !== except)
|
|
16
|
+
__defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return to2;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
@@ -27,11 +27,38 @@ __export(ContensisRoleService_exports, {
|
|
|
27
27
|
default: () => ContensisRoleService_default
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(ContensisRoleService_exports);
|
|
30
|
+
var import_await_to_js = __toESM(require("await-to-js"));
|
|
30
31
|
var import_ContensisCliService = __toESM(require("./ContensisCliService"));
|
|
32
|
+
var import_logger = require("../util/logger");
|
|
31
33
|
class ContensisRole extends import_ContensisCliService.default {
|
|
32
34
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
33
35
|
super(args, outputOpts, contensisOpts);
|
|
34
36
|
}
|
|
37
|
+
GetDeliveryApiKey = async () => {
|
|
38
|
+
const { contensis, currentEnv } = this;
|
|
39
|
+
const CMS = `https://cms-${currentEnv}.cloud.contensis.com`;
|
|
40
|
+
const API = "api/contensis-cli/settings/defaultDeliveryApiAccessToken";
|
|
41
|
+
if (contensis) {
|
|
42
|
+
const [error, bearerToken] = await (0, import_await_to_js.default)(
|
|
43
|
+
contensis.content.sourceRepo.repo.BearerToken()
|
|
44
|
+
);
|
|
45
|
+
if (error)
|
|
46
|
+
import_logger.Logger.error(error.message);
|
|
47
|
+
const token = fetch(`${CMS}/${API}`, {
|
|
48
|
+
method: "GET",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
Authorization: `Bearer ${bearerToken}`
|
|
52
|
+
}
|
|
53
|
+
}).then((repsonse) => repsonse.json()).then(({ value }) => {
|
|
54
|
+
if (value)
|
|
55
|
+
return value;
|
|
56
|
+
}).catch((error2) => {
|
|
57
|
+
throw new Error(error2);
|
|
58
|
+
});
|
|
59
|
+
return token;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
35
62
|
CreateOrUpdateApiKey = async (existingKey, name, description) => {
|
|
36
63
|
const { contensis, currentEnv, messages } = this;
|
|
37
64
|
if (!contensis)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/ContensisRoleService.ts"],
|
|
4
|
-
"sourcesContent": ["import { Role } from 'contensis-management-api/lib/models';\nimport { ApiKey, MigrateRequest } from 'migratortron';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": ["ContensisCli"]
|
|
4
|
+
"sourcesContent": ["import { Role } from 'contensis-management-api/lib/models';\nimport { ApiKey, MigrateRequest } from 'migratortron';\nimport to from 'await-to-js';\nimport ContensisCli from './ContensisCliService';\nimport { OutputOptionsConstructorArg } from '~/models/CliService';\nimport { Logger } from '~/util/logger';\n\nclass ContensisRole extends ContensisCli {\n constructor(\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n super(args, outputOpts, contensisOpts);\n }\n\n GetDeliveryApiKey = async () => {\n const { contensis, currentEnv } = this;\n\n const CMS = `https://cms-${currentEnv}.cloud.contensis.com`;\n const API = 'api/contensis-cli/settings/defaultDeliveryApiAccessToken';\n\n if (contensis) {\n const [error, bearerToken] = await to(\n contensis.content.sourceRepo.repo.BearerToken()\n );\n if (error) Logger.error(error.message);\n\n const token = fetch(`${CMS}/${API}`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n })\n .then(repsonse => repsonse.json())\n .then(({ value }) => {\n if (value) return value;\n })\n .catch(error => {\n throw new Error(error);\n });\n\n return token;\n }\n };\n\n CreateOrUpdateApiKey = async (\n existingKey: ApiKey | undefined,\n name: string,\n description: string\n ) => {\n const { contensis, currentEnv, messages } = this;\n if (!contensis) throw new Error('shouldnt be here');\n if (existingKey) {\n const [err, key] = await contensis.apiKeys.UpdateKey(existingKey.id, {\n name,\n description,\n });\n\n if (err)\n throw new Error(messages.keys.failedUpdate(currentEnv, name), {\n cause: err,\n });\n return key;\n } else {\n const [err, key] = await contensis.apiKeys.CreateKey(name, description);\n if (err)\n throw new Error(messages.keys.failedCreate(currentEnv, name), {\n cause: err,\n });\n\n return key;\n }\n };\n\n CreateOrUpdateRole = async (\n existingRole: Role | undefined,\n role: Partial<Role>\n ) => {\n const { contensis, currentEnv, messages } = this;\n if (!contensis) throw new Error('shouldnt be here');\n\n if (existingRole) {\n // TODO: check is update needed?\n const [err, updated] = await contensis.roles.UpdateRole(existingRole.id, {\n ...existingRole,\n ...role,\n });\n if (err)\n throw new Error(messages.roles.failedSet(currentEnv, role.name), {\n cause: err,\n });\n return updated;\n } else {\n const [err, created] = await contensis.roles.CreateRole(\n role as Omit<Role, 'id'>\n );\n if (err)\n throw new Error(messages.roles.failedCreate(currentEnv, role.name), {\n cause: err,\n });\n\n return created;\n }\n };\n}\nexport default ContensisRole;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAe;AACf,iCAAyB;AAEzB,oBAAuB;AAEvB,MAAM,sBAAsB,2BAAAA,QAAa;AAAA,EACvC,YACE,MACA,YACA,gBAAyC,CAAC,GAC1C;AACA,UAAM,MAAM,YAAY,aAAa;AAAA,EACvC;AAAA,EAEA,oBAAoB,YAAY;AAC9B,UAAM,EAAE,WAAW,WAAW,IAAI;AAElC,UAAM,MAAM,eAAe;AAC3B,UAAM,MAAM;AAEZ,QAAI,WAAW;AACb,YAAM,CAAC,OAAO,WAAW,IAAI,UAAM,mBAAAC;AAAA,QACjC,UAAU,QAAQ,WAAW,KAAK,YAAY;AAAA,MAChD;AACA,UAAI;AAAO,6BAAO,MAAM,MAAM,OAAO;AAErC,YAAM,QAAQ,MAAM,GAAG,OAAO,OAAO;AAAA,QACnC,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,UAChB,eAAe,UAAU;AAAA,QAC3B;AAAA,MACF,CAAC,EACE,KAAK,cAAY,SAAS,KAAK,CAAC,EAChC,KAAK,CAAC,EAAE,MAAM,MAAM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QAC3C;AAAA,MACF;AACA,UAAI;AACF,cAAM,IAAI,MAAM,SAAS,MAAM,aAAa,YAAY,KAAK,IAAI,GAAG;AAAA,UAClE,OAAO;AAAA,QACT,CAAC;AAEH,aAAO;AAAA,IACT;AAAA,EACF;AACF;AACA,IAAO,+BAAQ;",
|
|
6
|
+
"names": ["ContensisCli", "to", "error"]
|
|
7
7
|
}
|
package/dist/util/diff.js
CHANGED
|
@@ -60,8 +60,10 @@ const diffFileContent = (existingContent, newContent) => {
|
|
|
60
60
|
if (part.added || part.removed) {
|
|
61
61
|
const colour = part.added ? "green" : part.removed ? "red" : "grey";
|
|
62
62
|
if (part.value !== "\n") {
|
|
63
|
-
if (needsNewLine)
|
|
63
|
+
if (needsNewLine) {
|
|
64
64
|
output.push("\n### --");
|
|
65
|
+
needsNewLine = false;
|
|
66
|
+
}
|
|
65
67
|
output.push(
|
|
66
68
|
`
|
|
67
69
|
${part.value.split("\n").map(
|
package/dist/util/diff.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/diff.ts"],
|
|
4
|
-
"sourcesContent": ["import chalk from 'chalk';\nimport { Change, diffLines } from 'diff';\nimport { normaliseLineEndings } from './os';\n\nexport const diffLogStrings = (updates: string, previous: string) => {\n const lastFewLines = previous.split('\\n').slice(-10);\n const incomingLines = updates.split('\\n');\n\n // Find the line indices in the incoming lines\n // of the last few lines previously rendered\n const incomingLineIndices = [];\n for (const lastRenderedLine of lastFewLines) {\n if (lastRenderedLine.length > 10)\n incomingLineIndices.push(incomingLines.lastIndexOf(lastRenderedLine));\n }\n\n // Get the new lines from the next position on from the last of the already shown lines\n const differentFromPos = Math.max(...incomingLineIndices) + 1 || 0;\n // Return just the incoming lines from the position we matched\n return incomingLines.slice(differentFromPos).join('\\n');\n};\n\nexport const diffFileContent = (\n existingContent: string,\n newContent: string\n) => {\n const existingContentNormalised = normaliseLineEndings(existingContent, '\\n');\n const newContentNormalised = normaliseLineEndings(newContent, '\\n');\n\n const diff = diffLines(existingContentNormalised, newContentNormalised, {\n newlineIsToken: true,\n });\n const diffRanges = addDiffPositionInfo(diff);\n\n // Create formatted output for console\n const output: string[] = [];\n const lnSpaceLength = Math.max(\n ...diffRanges.map(d => d.startLineNumber.toString().length)\n );\n\n const lnSpaces = Array(lnSpaceLength).join(' ');\n\n let needsNewLine = false;\n for (let i = 0; i < diffRanges.length; i++) {\n const part = diffRanges[i];\n if (part.added || part.removed) {\n const colour = part.added ? 'green' : part.removed ? 'red' : 'grey';\n\n if (part.value !== '\\n') {\n if (needsNewLine) output.push('\\n### --');\n output.push(\n `\\n${part.value\n .split('\\n')\n .map((ln, idx) =>\n ln.trim() !== ''\n ? `${\n part.startLineNumber ? part.startLineNumber + idx : lnSpaces\n }${part.added ? '+' : part.removed ? '-' : ' '} ${chalk[\n colour\n ](`${ln}`)}`\n : ln\n )\n .join('\\n')}`\n );\n } else needsNewLine = true;\n } else needsNewLine = true;\n }\n\n return output.join('');\n};\n\nconst addDiffPositionInfo = (diff: Change[]) => {\n const diffRanges: (Change & {\n startLineNumber: number;\n startColumn: number;\n endLineNumber: number;\n endColumn: number;\n })[] = [];\n\n let lineNumber = 0;\n let column = 0;\n for (let partIndex = 0; partIndex < diff.length; partIndex++) {\n const part = diff[partIndex];\n\n // // Skip any parts that aren't in `after`\n // if (part.removed === true) {\n // continue;\n // }\n\n const startLineNumber = lineNumber;\n const startColumn = column;\n\n // Split the part into lines. Loop throug these lines to find\n // the line no. and column at the end of this part.\n const substring = part.value;\n const lines = substring.split('\\n');\n lines.forEach((line, lineIndex) => {\n // The first `line` is actually just a continuation of the last line\n if (lineIndex === 0) {\n column += line.length;\n // All other lines come after a line break.\n } else if (lineIndex > 0) {\n lineNumber += 1;\n column = line.length;\n }\n });\n\n // Save a range for all of the parts with position info added\n if (part.added === true || part.removed === true) {\n diffRanges.push({\n startLineNumber: startLineNumber + 1,\n startColumn: startColumn,\n endL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AI;
|
|
4
|
+
"sourcesContent": ["import chalk from 'chalk';\nimport { Change, diffLines } from 'diff';\nimport { normaliseLineEndings } from './os';\n\nexport const diffLogStrings = (updates: string, previous: string) => {\n const lastFewLines = previous.split('\\n').slice(-10);\n const incomingLines = updates.split('\\n');\n\n // Find the line indices in the incoming lines\n // of the last few lines previously rendered\n const incomingLineIndices = [];\n for (const lastRenderedLine of lastFewLines) {\n if (lastRenderedLine.length > 10)\n incomingLineIndices.push(incomingLines.lastIndexOf(lastRenderedLine));\n }\n\n // Get the new lines from the next position on from the last of the already shown lines\n const differentFromPos = Math.max(...incomingLineIndices) + 1 || 0;\n // Return just the incoming lines from the position we matched\n return incomingLines.slice(differentFromPos).join('\\n');\n};\n\nexport const diffFileContent = (\n existingContent: string,\n newContent: string\n) => {\n const existingContentNormalised = normaliseLineEndings(existingContent, '\\n');\n const newContentNormalised = normaliseLineEndings(newContent, '\\n');\n\n const diff = diffLines(existingContentNormalised, newContentNormalised, {\n newlineIsToken: true,\n });\n const diffRanges = addDiffPositionInfo(diff);\n\n // Create formatted output for console\n const output: string[] = [];\n const lnSpaceLength = Math.max(\n ...diffRanges.map(d => d.startLineNumber.toString().length)\n );\n\n const lnSpaces = Array(lnSpaceLength).join(' ');\n\n let needsNewLine = false;\n for (let i = 0; i < diffRanges.length; i++) {\n const part = diffRanges[i];\n if (part.added || part.removed) {\n const colour = part.added ? 'green' : part.removed ? 'red' : 'grey';\n\n if (part.value !== '\\n') {\n if (needsNewLine) {\n output.push('\\n### --');\n needsNewLine = false;\n }\n output.push(\n `\\n${part.value\n .split('\\n')\n .map((ln, idx) =>\n ln.trim() !== ''\n ? `${\n part.startLineNumber ? part.startLineNumber + idx : lnSpaces\n }${part.added ? '+' : part.removed ? '-' : ' '} ${chalk[\n colour\n ](`${ln}`)}`\n : ln\n )\n .join('\\n')}`\n );\n } else needsNewLine = true;\n } else needsNewLine = true;\n }\n\n return output.join('');\n};\n\nconst addDiffPositionInfo = (diff: Change[]) => {\n const diffRanges: (Change & {\n startLineNumber: number;\n startColumn: number;\n endLineNumber: number;\n endColumn: number;\n })[] = [];\n\n let lineNumber = 0;\n let column = 0;\n for (let partIndex = 0; partIndex < diff.length; partIndex++) {\n const part = diff[partIndex];\n\n // // Skip any parts that aren't in `after`\n // if (part.removed === true) {\n // continue;\n // }\n\n const startLineNumber = lineNumber;\n const startColumn = column;\n\n // Split the part into lines. Loop throug these lines to find\n // the line no. and column at the end of this part.\n const substring = part.value;\n const lines = substring.split('\\n');\n lines.forEach((line, lineIndex) => {\n // The first `line` is actually just a continuation of the last line\n if (lineIndex === 0) {\n column += line.length;\n // All other lines come after a line break.\n } else if (lineIndex > 0) {\n lineNumber += 1;\n column = line.length;\n }\n });\n\n // Save a range for all of the parts with position info added\n if (part.added === true || part.removed === true) {\n diffRanges.push({\n startLineNumber: startLineNumber + 1,\n startColumn: startColumn,\n endLineNumber: lineNumber,\n endColumn: column,\n ...part,\n });\n }\n }\n return diffRanges;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,kBAAkC;AAClC,gBAAqC;AAE9B,MAAM,iBAAiB,CAAC,SAAiB,aAAqB;AACnE,QAAM,eAAe,SAAS,MAAM,IAAI,EAAE,MAAM,GAAG;AACnD,QAAM,gBAAgB,QAAQ,MAAM,IAAI;AAIxC,QAAM,sBAAsB,CAAC;AAC7B,aAAW,oBAAoB,cAAc;AAC3C,QAAI,iBAAiB,SAAS;AAC5B,0BAAoB,KAAK,cAAc,YAAY,gBAAgB,CAAC;AAAA,EACxE;AAGA,QAAM,mBAAmB,KAAK,IAAI,GAAG,mBAAmB,IAAI,KAAK;AAEjE,SAAO,cAAc,MAAM,gBAAgB,EAAE,KAAK,IAAI;AACxD;AAEO,MAAM,kBAAkB,CAC7B,iBACA,eACG;AACH,QAAM,gCAA4B,gCAAqB,iBAAiB,IAAI;AAC5E,QAAM,2B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,UAAU,MAAM,IAAI;AAClC,UAAM,QAAQ,CAAC,MAAM,cAAc;AAEjC,UAAI,cAAc,GAAG;AACnB,kBAAU,KAAK;AAAA,MAEjB,WAAW,YAAY,GAAG;AACxB,sBAAc;AACd,iBAAS,KAAK;AAAA,MAChB;AAAA,IACF,CAAC;AAGD,QAAI,KAAK,UAAU,QAAQ,KAAK,YAAY,MAAM;AAChD,iBAAW,KAAK;AAAA,QACd,iBAAiB,kBAAkB;AAAA,QACnC;AAAA,QACA,eAAe;AAAA,QACf,WAAW;AAAA,QACX,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/util/git.js
CHANGED
|
@@ -108,9 +108,11 @@ class GitHelper {
|
|
|
108
108
|
const workflowPath = import_path.default.join(this.gitcwd(), ".github/workflows");
|
|
109
109
|
const workflowFiles = (0, import_file_provider.readFiles)(workflowPath, false);
|
|
110
110
|
const addFolderSuffix = (files) => files.map((f) => `.github/workflows/${f}`);
|
|
111
|
-
if (workflowFiles.some((f) => f.includes("build")))
|
|
111
|
+
if (workflowFiles.some((f) => f.includes("build"))) {
|
|
112
112
|
return addFolderSuffix(workflowFiles.filter((f) => f.includes("build")));
|
|
113
|
-
|
|
113
|
+
} else {
|
|
114
|
+
return addFolderSuffix(workflowFiles);
|
|
115
|
+
}
|
|
114
116
|
};
|
|
115
117
|
gitlabWorkflow = (ciFileName = GITLAB_CI_FILENAME) => {
|
|
116
118
|
const workflowPath = this.gitcwd();
|
package/dist/util/git.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/git.ts"],
|
|
4
|
-
"sourcesContent": ["import giturl from 'giturl';\nimport hostedGitInfo from 'hosted-git-info';\nimport parseGitConfig from 'parse-git-config';\nimport path from 'path';\n\nimport { linuxSlash } from './os';\nimport { readFile, readFiles } from '~/providers/file-provider';\n\nconst GITLAB_CI_FILENAME = '.gitlab-ci.yml';\n\ntype GitConfig = parseGitConfig.Config;\n\nexport type GitTypes = hostedGitInfo.Hosts;\n\nexport class GitHelper {\n private gitRepoPath: string;\n private ciFile?: string;\n\n config = {} as GitConfig;\n info: hostedGitInfo | undefined;\n home: string | undefined;\n\n set ciFileName(fileName: string) {\n this.ciFile = fileName;\n }\n\n get ciFileName() {\n return (\n this.ciFile ||\n (this.workflows\n ? this.type === 'github'\n ? this.workflows.length > 1\n ? '[multiple workflows]'\n : this.workflows?.[0]\n : GITLAB_CI_FILENAME\n : '[unknown]')\n );\n }\n get ciFilePath() {\n return `${this.gitRepoPath}/${this.ciFileName}`;\n }\n get name() {\n return (\n this.info?.project || this.home?.split('/').pop() || '[set arg --name]'\n );\n }\n get originUrl() {\n return this.config.remote.origin.url;\n }\n get secretsUri() {\n return `${\n this.type === 'github'\n ? `${this.home}/settings/secrets/actions`\n : `${this.home}/-/settings/ci_cd`\n }`;\n }\n get type() {\n return this.info?.type || this.hostType();\n }\n get workflows() {\n return this.type === 'github'\n ? this.githubWorkflows()\n : this.gitlabWorkflow();\n }\n constructor(gitRepoPath: string = process.cwd()) {\n this.gitRepoPath = gitRepoPath;\n this.config = this.gitConfig();\n this.home = giturl.parse(this.originUrl);\n this.info = this.gitInfo();\n // console.log(this.config);\n // console.log(this.home);\n // console.log(this.info);\n }\n gitcwd = () => path.join(this.gitRepoPath);\n gitInfo = (url: string = this.originUrl) => hostedGitInfo.fromUrl(url);\n hostType = (url: string = this.originUrl): GitTypes => {\n if (url.includes('github.com')) return 'github';\n return 'gitlab';\n // if (url.includes('gitlab.com')) return 'gl';\n // if (url.includes('gitlab.zengenti.com')) return 'gl';\n };\n gitConfig = (cwd = this.gitRepoPath) => {\n // Find .git/config in project cwd\n const config = parseGitConfig.sync({\n path: '.git/config',\n expandKeys: true,\n });\n // console.log(cwd, config);\n if (Object.keys(config || {}).length) return config;\n\n // Recursively check the directory heirarchy for existance of a .git/config\n const pathParts = linuxSlash(cwd).split('/');\n for (let i = 1; i <= pathParts.length; i++) {\n const relPath = `${Array(i).fill('..').join('/')}/.git/config`;\n // Does not appear to work when using a shortened cwd, using relative path instead\n const config = parseGitConfig.sync({\n path: relPath,\n expandKeys: true,\n });\n // console.log(relPath, config);\n if (Object.keys(config || {}).length) {\n this.gitRepoPath = path.join(\n this.gitRepoPath,\n Array(i).fill('..').join('/')\n );\n return config;\n }\n }\n return config;\n };\n githubWorkflows = () => {\n const workflowPath = path.join(this.gitcwd(), '.github/workflows');\n const workflowFiles = readFiles(workflowPath, false);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,6BAA0B;AAC1B,8BAA2B;AAC3B,kBAAiB;AAEjB,gBAA2B;AAC3B,2BAAoC;AAEpC,MAAM,qBAAqB;AAMpB,MAAM,UAAU;AAAA,EACb;AAAA,EACA;AAAA,EAER,SAAS,CAAC;AAAA,EACV;AAAA,EACA;AAAA,EAEA,IAAI,WAAW,UAAkB;AAC/B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAI,aAAa;AA1BnB;AA2BI,WACE,KAAK,WACJ,KAAK,YACF,KAAK,SAAS,WACZ,KAAK,UAAU,SAAS,IACtB,0BACA,UAAK,cAAL,mBAAiB,KACnB,qBACF;AAAA,EAER;AAAA,EACA,IAAI,aAAa;AACf,WAAO,GAAG,KAAK,eAAe,KAAK;AAAA,EACrC;AAAA,EACA,IAAI,OAAO;AAzCb;AA0CI,aACE,UAAK,SAAL,mBAAW,cAAW,UAAK,SAAL,mBAAW,MAAM,KAAK,UAAS;AAAA,EAEzD;AAAA,EACA,IAAI,YAAY;AACd,WAAO,KAAK,OAAO,OAAO,OAAO;AAAA,EACnC;AAAA,EACA,IAAI,aAAa;AACf,WAAO,GACL,KAAK,SAAS,WACV,GAAG,KAAK,kCACR,GAAG,KAAK;AAAA,EAEh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AAK,GAAG;AAAA,QAC9B;AACA,eAAOG;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,kBAAkB,MAAM;AACtB,UAAM,eAAe,YAAAH,QAAK,KAAK,KAAK,OAAO,GAAG,mBAAmB;AACjE,UAAM,oBAAgB,gCAAU,cAAc,KAAK;
|
|
4
|
+
"sourcesContent": ["import giturl from 'giturl';\nimport hostedGitInfo from 'hosted-git-info';\nimport parseGitConfig from 'parse-git-config';\nimport path from 'path';\n\nimport { linuxSlash } from './os';\nimport { readFile, readFiles } from '~/providers/file-provider';\n\nconst GITLAB_CI_FILENAME = '.gitlab-ci.yml';\n\ntype GitConfig = parseGitConfig.Config;\n\nexport type GitTypes = hostedGitInfo.Hosts;\n\nexport class GitHelper {\n private gitRepoPath: string;\n private ciFile?: string;\n\n config = {} as GitConfig;\n info: hostedGitInfo | undefined;\n home: string | undefined;\n\n set ciFileName(fileName: string) {\n this.ciFile = fileName;\n }\n\n get ciFileName() {\n return (\n this.ciFile ||\n (this.workflows\n ? this.type === 'github'\n ? this.workflows.length > 1\n ? '[multiple workflows]'\n : this.workflows?.[0]\n : GITLAB_CI_FILENAME\n : '[unknown]')\n );\n }\n get ciFilePath() {\n return `${this.gitRepoPath}/${this.ciFileName}`;\n }\n get name() {\n return (\n this.info?.project || this.home?.split('/').pop() || '[set arg --name]'\n );\n }\n get originUrl() {\n return this.config.remote.origin.url;\n }\n get secretsUri() {\n return `${\n this.type === 'github'\n ? `${this.home}/settings/secrets/actions`\n : `${this.home}/-/settings/ci_cd`\n }`;\n }\n get type() {\n return this.info?.type || this.hostType();\n }\n get workflows() {\n return this.type === 'github'\n ? this.githubWorkflows()\n : this.gitlabWorkflow();\n }\n constructor(gitRepoPath: string = process.cwd()) {\n this.gitRepoPath = gitRepoPath;\n this.config = this.gitConfig();\n this.home = giturl.parse(this.originUrl);\n this.info = this.gitInfo();\n // console.log(this.config);\n // console.log(this.home);\n // console.log(this.info);\n }\n gitcwd = () => path.join(this.gitRepoPath);\n gitInfo = (url: string = this.originUrl) => hostedGitInfo.fromUrl(url);\n hostType = (url: string = this.originUrl): GitTypes => {\n if (url.includes('github.com')) return 'github';\n return 'gitlab';\n // if (url.includes('gitlab.com')) return 'gl';\n // if (url.includes('gitlab.zengenti.com')) return 'gl';\n };\n gitConfig = (cwd = this.gitRepoPath) => {\n // Find .git/config in project cwd\n const config = parseGitConfig.sync({\n path: '.git/config',\n expandKeys: true,\n });\n // console.log(cwd, config);\n if (Object.keys(config || {}).length) return config;\n\n // Recursively check the directory heirarchy for existance of a .git/config\n const pathParts = linuxSlash(cwd).split('/');\n for (let i = 1; i <= pathParts.length; i++) {\n const relPath = `${Array(i).fill('..').join('/')}/.git/config`;\n // Does not appear to work when using a shortened cwd, using relative path instead\n const config = parseGitConfig.sync({\n path: relPath,\n expandKeys: true,\n });\n // console.log(relPath, config);\n if (Object.keys(config || {}).length) {\n this.gitRepoPath = path.join(\n this.gitRepoPath,\n Array(i).fill('..').join('/')\n );\n return config;\n }\n }\n return config;\n };\n githubWorkflows = () => {\n const workflowPath = path.join(this.gitcwd(), '.github/workflows');\n const workflowFiles = readFiles(workflowPath, false);\n const addFolderSuffix = (files: string[]) =>\n files.map(f => `.github/workflows/${f}`);\n\n if (workflowFiles.some(f => f.includes('build'))) {\n return addFolderSuffix(workflowFiles.filter(f => f.includes('build')));\n } else {\n return addFolderSuffix(workflowFiles);\n }\n };\n gitlabWorkflow = (ciFileName = GITLAB_CI_FILENAME) => {\n const workflowPath = this.gitcwd();\n const workflowFilePath = path.join(workflowPath, ciFileName);\n const workflowFile = readFile(workflowFilePath);\n // console.log(ciFileName, workflowFile);\n\n return workflowFile;\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,6BAA0B;AAC1B,8BAA2B;AAC3B,kBAAiB;AAEjB,gBAA2B;AAC3B,2BAAoC;AAEpC,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B,YAAAA,QAAK,KAAK,cAAc,UAAU;AAC3D,UAAM,mBAAe,+BAAS,gBAAgB;AAG9C,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": ["giturl", "path", "hostedGitInfo", "parseGitConfig", "config"]
|
|
7
7
|
}
|
package/dist/version.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
LIB_VERSION: () => LIB_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const LIB_VERSION = "1.0.0-beta.
|
|
24
|
+
const LIB_VERSION = "1.0.0-beta.97";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.0.0-beta.97\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.97",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": "https://github.com/contensis/node-cli",
|
|
6
6
|
"homepage": "https://github.com/contensis/node-cli/tree/main/packages/contensis-cli#readme",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"keytar": "^7.9.0",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"migratortron": "^1.0.0-beta.32",
|
|
43
|
+
"nanospinner": "^1.1.0",
|
|
43
44
|
"node-fetch": "^2.6.7",
|
|
44
45
|
"parse-git-config": "^3.0.0",
|
|
45
46
|
"patch-package": "^6.4.7",
|
package/src/commands/dev.ts
CHANGED
|
@@ -25,13 +25,13 @@ export const makeDevCommand = () => {
|
|
|
25
25
|
)
|
|
26
26
|
.option(
|
|
27
27
|
'-d --dry-run',
|
|
28
|
-
'perform a dry run of the project initialisation where no changes are made'
|
|
29
|
-
true
|
|
30
|
-
)
|
|
31
|
-
.option(
|
|
32
|
-
'--commit',
|
|
33
|
-
'commit change (will eventually be deprecated in favour of --dry-run)'
|
|
28
|
+
'perform a dry run of the project initialisation where no changes are made'
|
|
34
29
|
)
|
|
30
|
+
// .option(
|
|
31
|
+
// '--commit',
|
|
32
|
+
// 'commit change (will eventually be deprecated in favour of --dry-run)',
|
|
33
|
+
// true
|
|
34
|
+
// )
|
|
35
35
|
.addHelpText(
|
|
36
36
|
'after',
|
|
37
37
|
`
|
|
@@ -42,7 +42,7 @@ Example call:
|
|
|
42
42
|
// TODO: add opts for overriding project name and git url
|
|
43
43
|
await devCommand(['dev', 'init', projectHome], opts).DevelopmentInit(
|
|
44
44
|
projectHome,
|
|
45
|
-
{ ...opts, dryRun:
|
|
45
|
+
{ ...opts, dryRun: opts.dryRun }
|
|
46
46
|
);
|
|
47
47
|
});
|
|
48
48
|
|
package/src/commands/import.ts
CHANGED
|
@@ -133,6 +133,31 @@ Example call:
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
// TODO: add options to import one an array of nodes? nodeIds: string[]
|
|
137
|
+
program
|
|
138
|
+
.command('nodes')
|
|
139
|
+
.description('import nodes')
|
|
140
|
+
.addOption(commit)
|
|
141
|
+
.addHelpText(
|
|
142
|
+
'after',
|
|
143
|
+
`
|
|
144
|
+
Example call:
|
|
145
|
+
> import nodes --from-file component-backup.json
|
|
146
|
+
> import nodes --source-alias example-alias --source-project-id example-project
|
|
147
|
+
`
|
|
148
|
+
)
|
|
149
|
+
.action(async opts => {
|
|
150
|
+
await cliCommand(
|
|
151
|
+
['import', 'nodes'],
|
|
152
|
+
opts,
|
|
153
|
+
mapContensisOpts({ ...opts })
|
|
154
|
+
).ImportNodes({
|
|
155
|
+
commit: opts.commit,
|
|
156
|
+
fromFile: opts.fromFile,
|
|
157
|
+
logOutput: opts.outputNodes,
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
136
161
|
return program;
|
|
137
162
|
};
|
|
138
163
|
|