elestio 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/cli.js +2 -1
- package/src/commands/cicd.js +106 -25
package/README.md
CHANGED
|
@@ -257,6 +257,8 @@ Credentials and config are stored in `~/.elestio/`:
|
|
|
257
257
|
|
|
258
258
|
Get your API token from [Elestio Dashboard > Security](https://dash.elest.io/account/security).
|
|
259
259
|
|
|
260
|
+
## Documentation
|
|
261
|
+
https://docs.elest.io/books/elestio-cli-skill/page/overview
|
|
260
262
|
## License
|
|
261
263
|
|
|
262
264
|
MIT
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -759,7 +759,8 @@ export async function run(argv) {
|
|
|
759
759
|
buildDir: args['build-dir'], rootDir: args['root-dir'],
|
|
760
760
|
framework: args.framework, buildCmd: args['build-cmd'],
|
|
761
761
|
runCmd: args['run-cmd'], installCmd: args['install-cmd'],
|
|
762
|
-
nodeVersion: args['node-version'], variables: args.variables
|
|
762
|
+
nodeVersion: args['node-version'], variables: args.variables,
|
|
763
|
+
compose: args.compose
|
|
763
764
|
});
|
|
764
765
|
} else {
|
|
765
766
|
await cicd.createPipeline(args._[2] || args.file);
|
package/src/commands/cicd.js
CHANGED
|
@@ -251,16 +251,20 @@ async function getCicdTargetInfo(vmID, projectId) {
|
|
|
251
251
|
|
|
252
252
|
return {
|
|
253
253
|
displayName: target.displayName || target.name,
|
|
254
|
-
id:
|
|
254
|
+
id: target.id || target.serverID,
|
|
255
255
|
serverName: target.serverName || '',
|
|
256
|
-
vmID: String(target.providerServerID || target.vmID)
|
|
256
|
+
vmID: String(target.providerServerID || target.vmID),
|
|
257
|
+
vmProvider: target.vmProvider || target.provider || '',
|
|
258
|
+
vmRegion: target.vmRegion || target.datacenter || '',
|
|
259
|
+
levelName: target.levelName || 'Elestio-services',
|
|
260
|
+
projectID: String(pid)
|
|
257
261
|
};
|
|
258
262
|
}
|
|
259
263
|
|
|
260
264
|
const RUNTIME_PRESETS = {
|
|
261
265
|
'static': { runtime: 'staticSPA', buildDir: '/dist', framework: 'Vite.js', buildCmd: 'npm run build', runCmd: '', installCmd: 'npm install', version: '20', containerPort: '3000' },
|
|
262
|
-
'node': { runtime: '
|
|
263
|
-
'docker': { runtime: '', buildDir: '/', framework: '', buildCmd: '', runCmd: '', installCmd: '', version: '', containerPort: '
|
|
266
|
+
'node': { runtime: 'NodeJs', buildDir: '/', framework: 'No Framework', buildCmd: 'npm run build', runCmd: 'npm start', installCmd: 'npm install', version: '20', containerPort: '3000' },
|
|
267
|
+
'docker': { runtime: 'NodeJs', buildDir: '/', framework: 'NoFramework', buildCmd: '', runCmd: '', installCmd: '', version: '20', containerPort: '3000' }
|
|
264
268
|
};
|
|
265
269
|
|
|
266
270
|
export async function autoCreatePipeline(options = {}) {
|
|
@@ -310,24 +314,59 @@ export async function autoCreatePipeline(options = {}) {
|
|
|
310
314
|
const branch = options.branch || 'main';
|
|
311
315
|
const gitHost = gitType === 'GITLAB' ? 'gitlab.com' : 'github.com';
|
|
312
316
|
|
|
317
|
+
const defaultCompose = `services:\n nginx:\n image: nginx:alpine\n ports:\n - "172.17.0.1:${preset.containerPort}:80"\n volumes:\n - ./html:/usr/share/nginx/html:ro`;
|
|
318
|
+
|
|
313
319
|
const payload = {
|
|
314
|
-
CICDMode: gitType || 'DOCKER',
|
|
315
|
-
pipelineName: options.name,
|
|
316
|
-
projectID: String(pid),
|
|
317
|
-
authID: authID ? String(authID) : '0',
|
|
318
|
-
ports: [{ protocol: 'HTTPS', targetProtocol: 'HTTP', listeningPort: '443', targetPort: '3000', public: true, targetIP: '172.17.0.1', path: '/', isAuth: false, login: '', password: '' }],
|
|
319
|
-
variables: options.variables || '',
|
|
320
320
|
cluster: { isCluster: false, createNew: false, target },
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
321
|
+
gitData: gitType ? { projectName: options.name, branch, repoUrl: `https://${gitHost}/${options.repo}`, cloneUrl: `https://${gitHost}/${options.repo}.git`, repoID: String(repoData.id), repo: options.repo.split('/')[1] } : {},
|
|
322
|
+
imageData: gitType
|
|
323
|
+
? { isPipelineTemplate: false }
|
|
324
|
+
: { isPrivate: false, compose: options.compose || defaultCompose, dockerExample: '', repoName: 'CustomDocker' },
|
|
325
|
+
configData: {
|
|
326
|
+
buildDir: options.buildDir || preset.buildDir,
|
|
327
|
+
rootDir: options.rootDir || '/',
|
|
328
|
+
runTime: preset.runtime,
|
|
329
|
+
buildCmd: options.buildCmd || preset.buildCmd,
|
|
330
|
+
runCmd: options.runCmd || preset.runCmd,
|
|
331
|
+
installCmd: options.installCmd || preset.installCmd,
|
|
332
|
+
framework: options.framework || preset.framework,
|
|
333
|
+
version: options.nodeVersion || preset.version
|
|
334
|
+
},
|
|
335
|
+
ports: [{
|
|
336
|
+
protocol: 'HTTPS', targetProtocol: 'HTTP', listeningPort: '443',
|
|
337
|
+
targetPort: parseInt(preset.containerPort) + 1, public: true,
|
|
338
|
+
targetIP: '172.17.0.1', path: '/', isAuth: false,
|
|
339
|
+
login: '', password: '', loginTitle: ''
|
|
340
|
+
}],
|
|
341
|
+
variables: options.variables || '',
|
|
342
|
+
isPublicGitRepo: repoData ? !repoData.private : false,
|
|
343
|
+
exposedPorts: [{ protocol: 'HTTP', hostPort: preset.containerPort, containerPort: preset.containerPort, interface: '172.17.0.1' }],
|
|
344
|
+
gitVolumeConfig: [{}],
|
|
345
|
+
isNeedToCreateRepo: false,
|
|
346
|
+
gitUserFormData: {
|
|
347
|
+
selectedUser: '', searchGitUser: '',
|
|
348
|
+
gitOrgsFilteredList: { GITHUB: [], GITLAB: [] },
|
|
349
|
+
gitOrgsList: [], selectedRepo: {},
|
|
350
|
+
thirdPartyRepoInput: '', gitScopesUsers: [],
|
|
351
|
+
thirdPartyRepoScopeName: '',
|
|
352
|
+
getGitScopeUser: { GITHUB: [], GITLAB: [] },
|
|
353
|
+
thirdPartyRepoName: '', thirdPartyRepoPrivate: false,
|
|
354
|
+
loadSearch: false
|
|
355
|
+
},
|
|
356
|
+
lifeCycleCommand: {
|
|
357
|
+
preInstallCommand: '', postInstallCommand: '',
|
|
358
|
+
preBackupCommand: '', postBackupCommand: '',
|
|
359
|
+
preRestoreCommand: '', postRestoreCommand: '',
|
|
360
|
+
preUpdateCommand: '', postUpdateCommand: '',
|
|
361
|
+
preDeployCommand: '', postDeployCommand: ''
|
|
362
|
+
},
|
|
363
|
+
monoRepoWorkSpaces: [''],
|
|
364
|
+
copyCommandConfig: [],
|
|
365
|
+
CICDMode: gitType || 'DockerCompose',
|
|
366
|
+
projectID: String(pid),
|
|
367
|
+
pipelineName: options.name,
|
|
328
368
|
isMovePipeline: false,
|
|
329
|
-
|
|
330
|
-
gitUserFormData: {}
|
|
369
|
+
authID: authID ? String(authID) : null
|
|
331
370
|
};
|
|
332
371
|
|
|
333
372
|
log('info', 'Creating pipeline...');
|
|
@@ -342,8 +381,8 @@ export async function autoCreatePipeline(options = {}) {
|
|
|
342
381
|
|
|
343
382
|
// ── Pipeline Template Generator ──
|
|
344
383
|
|
|
345
|
-
function basePorts(targetPort =
|
|
346
|
-
return [{ protocol: 'HTTPS', targetProtocol: 'HTTP', listeningPort: '443', targetPort, public: true, targetIP: '172.17.0.1', path: '/', isAuth: false, login: '', password: '' }];
|
|
384
|
+
function basePorts(targetPort = 3001) {
|
|
385
|
+
return [{ protocol: 'HTTPS', targetProtocol: 'HTTP', listeningPort: '443', targetPort, public: true, targetIP: '172.17.0.1', path: '/', isAuth: false, login: '', password: '', loginTitle: '' }];
|
|
347
386
|
}
|
|
348
387
|
|
|
349
388
|
function baseExposedPorts(hostPort = '3000', containerPort = '3000') {
|
|
@@ -351,16 +390,58 @@ function baseExposedPorts(hostPort = '3000', containerPort = '3000') {
|
|
|
351
390
|
}
|
|
352
391
|
|
|
353
392
|
function baseCluster() {
|
|
354
|
-
return { isCluster: false, createNew: false, target: { displayName: 'REPLACE', id: 'REPLACE', serverName: 'REPLACE', vmID: 'REPLACE' } };
|
|
393
|
+
return { isCluster: false, createNew: false, target: { displayName: 'REPLACE', id: 'REPLACE', serverName: 'REPLACE', vmID: 'REPLACE', vmProvider: 'REPLACE', vmRegion: 'REPLACE', levelName: 'Elestio-services', projectID: 'REPLACE' } };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function baseLifeCycleCommand() {
|
|
397
|
+
return {
|
|
398
|
+
preInstallCommand: '', postInstallCommand: '',
|
|
399
|
+
preBackupCommand: '', postBackupCommand: '',
|
|
400
|
+
preRestoreCommand: '', postRestoreCommand: '',
|
|
401
|
+
preUpdateCommand: '', postUpdateCommand: '',
|
|
402
|
+
preDeployCommand: '', postDeployCommand: ''
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function baseGitUserFormData() {
|
|
407
|
+
return {
|
|
408
|
+
selectedUser: '', searchGitUser: '',
|
|
409
|
+
gitOrgsFilteredList: { GITHUB: [], GITLAB: [] },
|
|
410
|
+
gitOrgsList: [], selectedRepo: {},
|
|
411
|
+
thirdPartyRepoInput: '', gitScopesUsers: [],
|
|
412
|
+
thirdPartyRepoScopeName: '',
|
|
413
|
+
getGitScopeUser: { GITHUB: [], GITLAB: [] },
|
|
414
|
+
thirdPartyRepoName: '', thirdPartyRepoPrivate: false,
|
|
415
|
+
loadSearch: false
|
|
416
|
+
};
|
|
355
417
|
}
|
|
356
418
|
|
|
357
419
|
export function generatePipelineTemplate(mode = 'docker') {
|
|
420
|
+
const defaultCompose = 'services:\n nginx:\n image: nginx:alpine\n ports:\n - "172.17.0.1:3000:80"\n volumes:\n - ./html:/usr/share/nginx/html:ro';
|
|
421
|
+
|
|
358
422
|
const templates = {
|
|
359
|
-
docker: {
|
|
360
|
-
|
|
423
|
+
docker: {
|
|
424
|
+
cluster: baseCluster(), gitData: {}, imageData: { isPrivate: false, compose: defaultCompose, dockerExample: '', repoName: 'CustomDocker' },
|
|
425
|
+
configData: { buildDir: '/', rootDir: '/', runTime: 'NodeJs', buildCmd: '', runCmd: '', installCmd: '', framework: 'NoFramework', version: '20' },
|
|
426
|
+
ports: basePorts(), variables: '', isPublicGitRepo: false,
|
|
427
|
+
exposedPorts: baseExposedPorts('3000', '3000'), gitVolumeConfig: [{}], isNeedToCreateRepo: false,
|
|
428
|
+
gitUserFormData: baseGitUserFormData(), lifeCycleCommand: baseLifeCycleCommand(),
|
|
429
|
+
monoRepoWorkSpaces: [''], copyCommandConfig: [],
|
|
430
|
+
CICDMode: 'DockerCompose', projectID: 'REPLACE', pipelineName: 'REPLACE', isMovePipeline: false, authID: null
|
|
431
|
+
},
|
|
432
|
+
github: {
|
|
433
|
+
cluster: baseCluster(), gitData: { projectName: 'REPLACE', branch: 'main', repoUrl: 'https://github.com/OWNER/REPO', cloneUrl: 'https://github.com/OWNER/REPO.git', repoID: 'REPLACE', repo: 'OWNER/REPO' },
|
|
434
|
+
imageData: { isPipelineTemplate: false },
|
|
435
|
+
configData: { buildDir: '/dist', rootDir: '/', runTime: 'staticSPA', version: '20', framework: 'Vite.js', buildCmd: 'npm run build', runCmd: '', installCmd: 'npm install' },
|
|
436
|
+
ports: basePorts(), variables: '', isPublicGitRepo: false,
|
|
437
|
+
exposedPorts: baseExposedPorts(), gitVolumeConfig: [{}], isNeedToCreateRepo: false,
|
|
438
|
+
gitUserFormData: baseGitUserFormData(), lifeCycleCommand: baseLifeCycleCommand(),
|
|
439
|
+
monoRepoWorkSpaces: [''], copyCommandConfig: [],
|
|
440
|
+
CICDMode: 'GITHUB', projectID: 'REPLACE', pipelineName: 'REPLACE', isMovePipeline: false, authID: 'REPLACE'
|
|
441
|
+
}
|
|
361
442
|
};
|
|
362
443
|
|
|
363
|
-
templates['github-fullstack'] = { ...templates.github, configData: { buildDir: '/', rootDir: '/',
|
|
444
|
+
templates['github-fullstack'] = { ...templates.github, configData: { buildDir: '/', rootDir: '/', runTime: 'NodeJs', version: '20', framework: 'No Framework', buildCmd: 'npm run build', runCmd: 'npm start', installCmd: 'npm install' } };
|
|
364
445
|
templates.gitlab = { ...templates.github, CICDMode: 'GITLAB', gitData: { ...templates.github.gitData, repoUrl: 'https://gitlab.com/OWNER/REPO', cloneUrl: 'https://gitlab.com/OWNER/REPO.git' } };
|
|
365
446
|
templates['gitlab-fullstack'] = { ...templates['github-fullstack'], CICDMode: 'GITLAB', gitData: { ...templates.github.gitData, repoUrl: 'https://gitlab.com/OWNER/REPO', cloneUrl: 'https://gitlab.com/OWNER/REPO.git' } };
|
|
366
447
|
|