118 lines
3.9 KiB
JavaScript
118 lines
3.9 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const execa = require('execa');
|
|
const Listr = require('listr');
|
|
const package = require('../../../package.json');
|
|
|
|
const fs = require('fs');
|
|
|
|
if (!package.devops) throw `No devops configuration found in package.json`;
|
|
if (!package.devops.services) throw `No devops services found in package.json`;
|
|
if (!package.devops.awsProfile) throw `No devops awsProfile found in package.json`;
|
|
if (!package.devops.awsRegion) throw 'No devops awsRegion found in package.json';
|
|
|
|
// Config input
|
|
const awsProfile = package.devops.awsProfile;
|
|
const awsRegion = package.devops.awsRegion;
|
|
|
|
// Arguments checks
|
|
|
|
const deployBase = function() {
|
|
return new Listr(
|
|
[
|
|
{
|
|
title: 'Deploy domains for DEV',
|
|
task: async () => {
|
|
const subprocess = execa(
|
|
'npx',
|
|
[
|
|
'./node_modules/.bin/sls',
|
|
'create_domain',
|
|
'--config',
|
|
'./lib/seed/devops/serverless-domains.yaml',
|
|
'--stage',
|
|
'dev',
|
|
'--aws-profile',
|
|
awsProfile,
|
|
'--region',
|
|
awsRegion,
|
|
],
|
|
{ env: { 'SLS_DEBUG=*': '*' } },
|
|
);
|
|
|
|
subprocess.stdout.pipe(fs.createWriteStream('.slslogs.txt', { flags: 'a' }));
|
|
|
|
const { stdout } = await subprocess;
|
|
},
|
|
},
|
|
{
|
|
title: 'Deploy domains for STAGING',
|
|
task: async () => {
|
|
const subprocess = execa(
|
|
'npx',
|
|
[
|
|
'./node_modules/.bin/sls',
|
|
'create_domain',
|
|
'--config',
|
|
'./lib/seed/devops/serverless-domains.yaml',
|
|
'--stage',
|
|
'staging',
|
|
'--aws-profile',
|
|
awsProfile,
|
|
'--region',
|
|
awsRegion,
|
|
],
|
|
{ env: { 'SLS_DEBUG=*': '*' } },
|
|
);
|
|
|
|
subprocess.stdout.pipe(fs.createWriteStream('.slslogs.txt', { flags: 'a' }));
|
|
|
|
const { stdout } = await subprocess;
|
|
},
|
|
},
|
|
{
|
|
title: 'Deploy domains for PRODUCTION',
|
|
task: async () => {
|
|
const subprocess = execa(
|
|
'npx',
|
|
[
|
|
'./node_modules/.bin/sls',
|
|
'create_domain',
|
|
'--config',
|
|
'./lib/seed/devops/serverless-domains.yaml',
|
|
'--stage',
|
|
'production',
|
|
'--aws-profile',
|
|
awsProfile,
|
|
'--region',
|
|
awsRegion,
|
|
],
|
|
{ env: { 'SLS_DEBUG=*': '*' } },
|
|
);
|
|
|
|
subprocess.stdout.pipe(fs.createWriteStream('.slslogs.txt', { flags: 'a' }));
|
|
|
|
const { stdout } = await subprocess;
|
|
},
|
|
},
|
|
],
|
|
{ concurrent: false },
|
|
);
|
|
};
|
|
|
|
const tasksList = [];
|
|
|
|
tasksList.push({
|
|
title: 'Deploying Domains',
|
|
task: () => {
|
|
return deployBase();
|
|
},
|
|
});
|
|
|
|
const tasks = new Listr(tasksList, { concurrent: false });
|
|
|
|
tasks.run().catch((err) => {
|
|
console.error(err);
|
|
});
|