gasup 0.2.0 → 0.2.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/bin/gasup.js CHANGED
@@ -4,11 +4,15 @@ import { bundle } from '../bundle.js';
4
4
  import { changeEnv } from '../changeEnv.js';
5
5
  import { init } from '../init.js';
6
6
  import inquirer from 'inquirer';
7
+ import { execSync } from 'child_process';
8
+ import { deploy } from '../deploy.js';
7
9
  program
8
10
  .option('--init', 'init')
9
11
  .option('--env <env>', 'change env')
10
12
  .option('--bundle', 'bundle')
11
13
  .option('--build', 'build')
14
+ .option('--push', 'push')
15
+ .option('--deploy', 'deploy')
12
16
  .parse();
13
17
  async function main() {
14
18
  if (program.opts().init) {
@@ -39,6 +43,14 @@ async function main() {
39
43
  console.log('bundle with esbuild');
40
44
  await bundle();
41
45
  }
46
+ if (program.opts().push) {
47
+ console.log('push');
48
+ execSync('clasp push', { stdio: 'inherit' });
49
+ }
50
+ if (program.opts().deploy) {
51
+ console.log(`deploy`);
52
+ deploy();
53
+ }
42
54
  console.log('gasup done');
43
55
  }
44
56
  try {
@@ -0,0 +1 @@
1
+ export declare function deploy(): void;
package/dist/deploy.js ADDED
@@ -0,0 +1,27 @@
1
+ import { execSync } from 'child_process';
2
+ export function deploy() {
3
+ const currentDeployments = getCurrentDeployments();
4
+ const latestDeployment = currentDeployments[0];
5
+ if (latestDeployment) {
6
+ console.log('deploy to latest: ' +
7
+ latestDeployment.id +
8
+ ' ' +
9
+ latestDeployment.version);
10
+ execSync('clasp deploy -i ' + latestDeployment.id);
11
+ }
12
+ else {
13
+ console.log('deploy new version');
14
+ execSync('clasp deploy');
15
+ }
16
+ }
17
+ function getCurrentDeployments() {
18
+ const res = execSync('clasp deployments').toString();
19
+ const lines = res.split('\n');
20
+ const deployments = lines
21
+ .filter((line) => line.startsWith('-'))
22
+ .map((line) => {
23
+ const [_, id, versionStr] = line.split(' ');
24
+ return { id, version: Number(versionStr.replace(/[^\d]/g, '')) };
25
+ });
26
+ return deployments.sort((a, b) => b.version - a.version);
27
+ }
package/dist/envFile.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs-extra';
2
- import { getConfig } from './config.js';
3
2
  import { getClaspJson } from './claspJson.js';
3
+ import { getConfig } from './config.js';
4
4
  export function initEnvFiles() {
5
5
  const config = getConfig();
6
6
  const claspJson = getClaspJson();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gasup",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "gasup": "./dist/bin/gasup.js"