carlin 1.28.2 → 1.29.1

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/cli.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.options = void 0;
29
+ exports.cli = exports.options = void 0;
30
30
  /* eslint-disable no-param-reassign */
31
31
  const yargs = __importStar(require("yargs"));
32
32
  const config_1 = require("./config");
@@ -43,9 +43,7 @@ const findup_sync_1 = __importDefault(require("findup-sync"));
43
43
  const path_1 = __importDefault(require("path"));
44
44
  const coerceSetEnvVar = (env) => {
45
45
  return (value) => {
46
- if (value) {
47
- (0, utils_1.setEnvVar)(env, value);
48
- }
46
+ (0, utils_1.setEnvVar)(env, value);
49
47
  return value;
50
48
  };
51
49
  };
@@ -267,4 +265,4 @@ const cli = () => {
267
265
  .epilogue('For more information, read our docs at https://ttoss.dev/docs/carlin/')
268
266
  .help());
269
267
  };
270
- exports.default = cli;
268
+ exports.cli = cli;
@@ -10,6 +10,7 @@ const command_2 = require("./cicd/command");
10
10
  const cloudFormation_1 = require("./cloudFormation");
11
11
  const command_3 = require("./lambdaLayer/command");
12
12
  const command_4 = require("./staticApp/command");
13
+ const command_5 = require("./vercel/command");
13
14
  const stackName_1 = require("./stackName");
14
15
  const cloudFormation_core_1 = require("./cloudFormation.core");
15
16
  const readDockerfile_1 = require("./readDockerfile");
@@ -23,6 +24,12 @@ const checkAwsAccountId = async (awsAccountId) => {
23
24
  }
24
25
  }
25
26
  catch (error) {
27
+ if (error.code === 'CredentialsError') {
28
+ /**
29
+ * No credentials found.
30
+ */
31
+ return;
32
+ }
26
33
  npmlog_1.default.error(logPrefix, error.message);
27
34
  process.exit();
28
35
  }
@@ -173,6 +180,7 @@ exports.deployCommand = {
173
180
  command_1.deployBaseStackCommand,
174
181
  command_4.deployStaticAppCommand,
175
182
  command_2.deployCicdCommand,
183
+ command_5.deployVercelCommand,
176
184
  ];
177
185
  yargsBuilder.positional('deploy', {
178
186
  choices: commands.map(({ command }) => {
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deployVercelCommand = exports.options = void 0;
7
+ const utils_1 = require("../../utils");
8
+ const deployVercel_1 = require("./deployVercel");
9
+ const npmlog_1 = __importDefault(require("npmlog"));
10
+ const logPrefix = 'deploy vercel';
11
+ exports.options = {
12
+ token: {
13
+ describe: 'Vercel authorization token.',
14
+ type: 'string',
15
+ },
16
+ };
17
+ exports.deployVercelCommand = {
18
+ command: 'vercel',
19
+ describe: 'Deploy on Vercel.',
20
+ builder: (yargs) => {
21
+ return yargs.options((0, utils_1.addGroupToOptions)(exports.options, 'Deploy on Vercel Options'));
22
+ },
23
+ handler: ({ destroy, ...rest }) => {
24
+ if (destroy) {
25
+ npmlog_1.default.info(logPrefix, 'Destroy Vercel deployment not implemented yet.');
26
+ }
27
+ else {
28
+ (0, deployVercel_1.deployVercel)(rest);
29
+ }
30
+ },
31
+ };
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deployVercel = void 0;
7
+ const utils_1 = require("../../utils");
8
+ const utils_2 = require("../utils");
9
+ const npmlog_1 = __importDefault(require("npmlog"));
10
+ const logPrefix = 'deploy vercel';
11
+ const makeCommand = (cmds) => {
12
+ return cmds
13
+ .filter((cmd) => {
14
+ return cmd !== undefined && cmd !== null && cmd !== '';
15
+ })
16
+ .join(' ');
17
+ };
18
+ /**
19
+ * https://vercel.com/docs/cli
20
+ */
21
+ const deployVercel = async ({ token }) => {
22
+ try {
23
+ npmlog_1.default.info(logPrefix, 'Deploying on Vercel...');
24
+ const environment = (0, utils_1.getEnvironment)();
25
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
26
+ const finalToken = token || process.env.VERCEL_TOKEN;
27
+ if (!finalToken) {
28
+ throw new Error('Missing Vercel token');
29
+ }
30
+ const cmdToken = finalToken ? `--token=${finalToken}` : '';
31
+ const cmdProdFlag = environment === 'Production' ? '--prod' : '';
32
+ const cmdEnvironment = `--environment=${environment === 'Production' ? 'production' : 'preview'}`;
33
+ const pullCmd = makeCommand([
34
+ 'vercel',
35
+ 'pull',
36
+ '--yes',
37
+ cmdEnvironment,
38
+ cmdToken,
39
+ ]);
40
+ await (0, utils_1.spawn)(pullCmd);
41
+ /**
42
+ * https://vercel.com/docs/cli/build
43
+ */
44
+ const buildCdm = makeCommand(['vercel', 'build', cmdProdFlag, cmdToken]);
45
+ await (0, utils_1.spawn)(buildCdm);
46
+ const deployCmd = makeCommand([
47
+ 'vercel',
48
+ 'deploy',
49
+ '--prebuilt',
50
+ cmdProdFlag,
51
+ cmdToken,
52
+ ]);
53
+ await (0, utils_1.spawn)(deployCmd);
54
+ }
55
+ catch (error) {
56
+ (0, utils_2.handleDeployError)({ error, logPrefix });
57
+ }
58
+ };
59
+ exports.deployVercel = deployVercel;
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const cli_1 = __importDefault(require("./cli"));
7
- (0, cli_1.default)().parse();
3
+ const cli_1 = require("./cli");
4
+ (0, cli_1.cli)().parse();
@@ -8,6 +8,9 @@ const getEnvVar = (key) => {
8
8
  };
9
9
  exports.getEnvVar = getEnvVar;
10
10
  const setEnvVar = (key, value) => {
11
+ if (!value) {
12
+ return cache.delete(key);
13
+ }
11
14
  return cache.set(key, value);
12
15
  };
13
16
  exports.setEnvVar = setEnvVar;
@@ -7,18 +7,20 @@ exports.exec = void 0;
7
7
  const child_process_1 = __importDefault(require("child_process"));
8
8
  const npmlog_1 = __importDefault(require("npmlog"));
9
9
  npmlog_1.default.heading = 'exec';
10
- const exec = (cmd) => new Promise((resolve, reject) => {
11
- child_process_1.default.exec(cmd, (error, stdout, stderr) => {
12
- if (error) {
13
- return reject(error);
14
- }
15
- if (stdout) {
16
- return resolve(stdout);
17
- }
18
- if (stderr) {
19
- return reject(stderr);
20
- }
21
- return resolve(undefined);
10
+ const exec = (cmd) => {
11
+ return new Promise((resolve, reject) => {
12
+ child_process_1.default.exec(cmd, (error, stdout, stderr) => {
13
+ if (error) {
14
+ return reject(error);
15
+ }
16
+ if (stdout) {
17
+ return resolve(stdout);
18
+ }
19
+ if (stderr) {
20
+ return reject(stderr);
21
+ }
22
+ return resolve(undefined);
23
+ });
22
24
  });
23
- });
25
+ };
24
26
  exports.exec = exec;
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.spawn = void 0;
17
18
  __exportStar(require("./addGroupToOptions"), exports);
18
19
  __exportStar(require("./codeBuild"), exports);
19
20
  __exportStar(require("./cloudFormationTemplate"), exports);
@@ -26,3 +27,5 @@ __exportStar(require("./getEnvironment"), exports);
26
27
  __exportStar(require("./getIamPath"), exports);
27
28
  __exportStar(require("./getProjectName"), exports);
28
29
  __exportStar(require("./packageJson"), exports);
30
+ var spawn_1 = require("./spawn");
31
+ Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return spawn_1.spawn; } });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.spawn = void 0;
7
+ const process_1 = require("process");
8
+ const child_process_1 = __importDefault(require("child_process"));
9
+ const npmlog_1 = __importDefault(require("npmlog"));
10
+ npmlog_1.default.heading = 'exec';
11
+ const spawn = (cmd) => {
12
+ return new Promise((resolve, reject) => {
13
+ const [cmdName, ...cmdArgs] = cmd.split(' ');
14
+ const child = child_process_1.default.spawn(cmdName, cmdArgs);
15
+ child.stdout.on('data', (data) => {
16
+ process_1.stdout.write(data);
17
+ });
18
+ child.stderr.on('data', (data) => {
19
+ process_1.stdout.write(data);
20
+ });
21
+ child.on('error', (error) => {
22
+ reject(error);
23
+ });
24
+ child.on('close', (code) => {
25
+ if (code === 0) {
26
+ resolve({});
27
+ }
28
+ else {
29
+ reject(code);
30
+ }
31
+ });
32
+ });
33
+ };
34
+ exports.spawn = spawn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carlin",
3
- "version": "1.28.2",
3
+ "version": "1.29.1",
4
4
  "description": "",
5
5
  "license": "GPL-3.0",
6
6
  "author": "Pedro Arantes <arantespp@gmail.com> (https://twitter.com/arantespp)",
@@ -21,11 +21,11 @@
21
21
  "dist/"
22
22
  ],
23
23
  "dependencies": {
24
- "@aws-sdk/client-cloudformation": "^3.321.1",
24
+ "@aws-sdk/client-cloudformation": "^3.329.0",
25
25
  "@octokit/webhooks": "^11.0.0",
26
26
  "@slack/webhook": "^6.1.0",
27
27
  "adm-zip": "^0.5.10",
28
- "aws-sdk": "^2.1367.0",
28
+ "aws-sdk": "^2.1374.0",
29
29
  "builtin-modules": "^3.3.0",
30
30
  "change-case": "^4.1.2",
31
31
  "deep-equal": "^2.2.1",
@@ -42,12 +42,13 @@
42
42
  "simple-git": "^3.18.0",
43
43
  "ts-node": "^10.9.1",
44
44
  "uglify-js": "^3.17.4",
45
+ "vercel": "^29.1.1",
45
46
  "yargs": "^17.7.2",
46
- "@ttoss/cloudformation": "^0.7.1"
47
+ "@ttoss/cloudformation": "^0.7.2"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/adm-zip": "^0.5.0",
50
- "@types/aws-lambda": "^8.10.114",
51
+ "@types/aws-lambda": "^8.10.115",
51
52
  "@types/deep-equal": "^1.0.1",
52
53
  "@types/findup-sync": "^4.0.2",
53
54
  "@types/glob": "^8.1.0",
@@ -56,11 +57,11 @@
56
57
  "@types/mime-types": "^2.1.1",
57
58
  "@types/node": "^18.16.2",
58
59
  "@types/npmlog": "^4.1.4",
59
- "@types/semver": "^7.3.13",
60
+ "@types/semver": "^7.5.0",
60
61
  "@types/uglify-js": "^3.17.1",
61
62
  "@types/yargs": "^17.0.24",
62
63
  "jest": "^29.5.0",
63
- "@ttoss/test-utils": "^1.23.0"
64
+ "@ttoss/test-utils": "^1.23.1"
64
65
  },
65
66
  "keywords": [],
66
67
  "publishConfig": {
@@ -68,7 +69,6 @@
68
69
  },
69
70
  "scripts": {
70
71
  "build": "tsc",
71
- "lint": "eslint src",
72
- "test": "jest --changedSince=$LATEST_TAG"
72
+ "test": "jest"
73
73
  }
74
74
  }