@naturalcycles/backend-lib 4.22.0 → 4.23.0
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
+
const deployGae_1 = require("../deploy/deployGae");
|
|
6
|
+
(0, nodejs_lib_1.runScript)(async () => {
|
|
7
|
+
await (0, deployGae_1.undeployGae)();
|
|
8
|
+
});
|
|
@@ -3,3 +3,8 @@ import { DeployPrepareOptions } from './deployPrepare';
|
|
|
3
3
|
export interface DeployGaeOptions extends DeployPrepareOptions, DeployHealthCheckOptions {
|
|
4
4
|
}
|
|
5
5
|
export declare function deployGae(opt?: DeployGaeOptions): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Undeploys/removes the GAE service/version, using the same rules as deployGae.
|
|
8
|
+
* Detects the service/version by the same criteria: branch name, backend.cfg.yaml, etc.
|
|
9
|
+
*/
|
|
10
|
+
export declare function undeployGae(): Promise<void>;
|
package/dist/deploy/deployGae.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployGae = void 0;
|
|
3
|
+
exports.undeployGae = exports.deployGae = void 0;
|
|
4
4
|
const dev_lib_1 = require("@naturalcycles/dev-lib");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
@@ -57,6 +57,20 @@ async function deployGae(opt = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.deployGae = deployGae;
|
|
60
|
+
/**
|
|
61
|
+
* Undeploys/removes the GAE service/version, using the same rules as deployGae.
|
|
62
|
+
* Detects the service/version by the same criteria: branch name, backend.cfg.yaml, etc.
|
|
63
|
+
*/
|
|
64
|
+
async function undeployGae() {
|
|
65
|
+
const { gaeProject, gaeService, gaeVersion, prod } = await (0, deployPrepare_1.deployPrepare)();
|
|
66
|
+
if (prod) {
|
|
67
|
+
console.log('undeployGae: not removing prod version (safety check)');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
console.log(`undeployGae: going to remove ${gaeProject}/${gaeService}/${gaeVersion}`);
|
|
71
|
+
(0, nodejs_lib_1.execVoidCommandSync)(`gcloud app versions delete --project ${gaeProject} --service ${gaeService} ${gaeVersion} --quiet`, [], { shell: true });
|
|
72
|
+
}
|
|
73
|
+
exports.undeployGae = undeployGae;
|
|
60
74
|
function logs(gaeProject, gaeService, gaeVersion) {
|
|
61
75
|
try {
|
|
62
76
|
(0, nodejs_lib_1.execVoidCommandSync)(`gcloud app logs read --project ${gaeProject} --service ${gaeService} --version ${gaeVersion}`, [], { shell: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.23.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
],
|
|
61
61
|
"bin": {
|
|
62
62
|
"deploy-gae": "dist/bin/deploy-gae.js",
|
|
63
|
+
"undeploy-gae": "dist/bin/undeploy-gae.js",
|
|
63
64
|
"deploy-prepare": "dist/bin/deploy-prepare.js",
|
|
64
65
|
"deploy-health-check": "dist/bin/deploy-health-check.js"
|
|
65
66
|
},
|
package/src/deploy/deployGae.ts
CHANGED
|
@@ -79,6 +79,27 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Undeploys/removes the GAE service/version, using the same rules as deployGae.
|
|
84
|
+
* Detects the service/version by the same criteria: branch name, backend.cfg.yaml, etc.
|
|
85
|
+
*/
|
|
86
|
+
export async function undeployGae(): Promise<void> {
|
|
87
|
+
const { gaeProject, gaeService, gaeVersion, prod } = await deployPrepare()
|
|
88
|
+
|
|
89
|
+
if (prod) {
|
|
90
|
+
console.log('undeployGae: not removing prod version (safety check)')
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.log(`undeployGae: going to remove ${gaeProject}/${gaeService}/${gaeVersion}`)
|
|
95
|
+
|
|
96
|
+
execVoidCommandSync(
|
|
97
|
+
`gcloud app versions delete --project ${gaeProject} --service ${gaeService} ${gaeVersion} --quiet`,
|
|
98
|
+
[],
|
|
99
|
+
{ shell: true },
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
82
103
|
function logs(gaeProject: string, gaeService: string, gaeVersion: string): void {
|
|
83
104
|
try {
|
|
84
105
|
execVoidCommandSync(
|