@platforma-sdk/bootstrap 2.0.0 → 2.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/assets/compose-backend.yaml +6 -6
- package/dist/cmd-opts.d.ts +6 -3
- package/dist/cmd-opts.d.ts.map +1 -1
- package/dist/commands/start/docker/s3.d.ts +6 -3
- package/dist/commands/start/docker/s3.d.ts.map +1 -1
- package/dist/commands/start/docker.d.ts +6 -3
- package/dist/commands/start/docker.d.ts.map +1 -1
- package/dist/commands/start/local/s3.d.ts +6 -3
- package/dist/commands/start/local/s3.d.ts.map +1 -1
- package/dist/commands/start/local.d.ts +6 -3
- package/dist/commands/start/local.d.ts.map +1 -1
- package/dist/core.d.ts +15 -6
- package/dist/core.d.ts.map +1 -1
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +947 -487
- package/dist/index.mjs.map +1 -1
- package/dist/package.d.ts +0 -1
- package/dist/package.d.ts.map +1 -1
- package/dist/platforma.d.ts.map +1 -1
- package/dist/state.d.ts +3 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/templates/pl-config.d.ts.map +1 -1
- package/dist/templates/types.d.ts +6 -0
- package/dist/templates/types.d.ts.map +1 -1
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/package.json +14 -9
- package/src/block.ts +0 -82
- package/src/cmd-opts.ts +0 -175
- package/src/commands/create-block.ts +0 -21
- package/src/commands/reset.ts +0 -23
- package/src/commands/start/docker/s3.ts +0 -59
- package/src/commands/start/docker.ts +0 -65
- package/src/commands/start/local/s3.ts +0 -96
- package/src/commands/start/local.ts +0 -89
- package/src/commands/start.ts +0 -23
- package/src/commands/stop.ts +0 -23
- package/src/core.ts +0 -696
- package/src/index.ts +0 -10
- package/src/package.ts +0 -54
- package/src/platforma.ts +0 -194
- package/src/run.ts +0 -120
- package/src/state.ts +0 -105
- package/src/templates/pl-config.ts +0 -280
- package/src/templates/types.ts +0 -172
- package/src/util.ts +0 -55
|
@@ -33,15 +33,21 @@ export type logSettings = {
|
|
|
33
33
|
export type logOptions = DeepPartial<logSettings>;
|
|
34
34
|
export type coreSettings = {
|
|
35
35
|
auth: authSettings;
|
|
36
|
+
db: dbSettings;
|
|
36
37
|
};
|
|
37
38
|
export type coreOptions = {
|
|
38
39
|
auth?: authOptions;
|
|
40
|
+
db?: dbOptions;
|
|
39
41
|
};
|
|
40
42
|
export type authSettings = {
|
|
41
43
|
enabled: boolean;
|
|
42
44
|
drivers: authDriver[];
|
|
43
45
|
};
|
|
44
46
|
export type authOptions = Partial<authSettings>;
|
|
47
|
+
export type dbSettings = {
|
|
48
|
+
path: string;
|
|
49
|
+
};
|
|
50
|
+
export type dbOptions = Partial<dbSettings>;
|
|
45
51
|
export type authDriver = {
|
|
46
52
|
driver: 'ldap';
|
|
47
53
|
serverUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/templates/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,EAAE,eAAe,CAAC;IACzB,GAAG,EAAE,WAAW,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,gBAAgB,CAAC;IAE3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,aAAa,CAAC;IAErB,KAAK,EAAE;QACL,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH,CAAC;AACF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,IAAI,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nB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ export declare function assertNever(n: never): void;
|
|
|
4
4
|
export declare function createLogger(level?: string): winston.Logger;
|
|
5
5
|
export declare function randomStr(len: number): string;
|
|
6
6
|
export declare function resolveTilde(p: string): string;
|
|
7
|
+
export declare function ensureDir(p: string): void;
|
|
8
|
+
export declare function getProcessName(pid: number): string;
|
|
7
9
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAKA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG7C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,QAEnC;AAED,wBAAgB,YAAY,CAAC,KAAK,GAAE,MAAgB,GAAG,OAAO,CAAC,MAAM,CAyBpE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,QAMlC;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/bootstrap",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"pl-version": "1.13.0",
|
|
5
5
|
"description": "MiLaboratories Platforma Backend bootstrap code: configuration generators, service run wrappers and so on",
|
|
6
6
|
"bin": {
|
|
@@ -8,27 +8,28 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"./dist/**/*",
|
|
11
|
-
"./src/**/*",
|
|
12
11
|
"README.md",
|
|
13
12
|
"bin/run.cmd",
|
|
14
13
|
"bin/run.js",
|
|
15
|
-
"assets",
|
|
16
|
-
"postinstall.js"
|
|
14
|
+
"./assets/**",
|
|
15
|
+
"./postinstall.js"
|
|
17
16
|
],
|
|
18
17
|
"keywords": [],
|
|
19
18
|
"license": "UNLICENSED",
|
|
20
19
|
"devDependencies": {
|
|
21
|
-
"vite": "^5.4.8",
|
|
22
20
|
"@types/decompress": "^4.2.7",
|
|
23
21
|
"@types/jest": "^29.5.13",
|
|
24
22
|
"@types/node": "~20.16.5",
|
|
25
23
|
"@types/readline-sync": "^1.4.8",
|
|
24
|
+
"jest": "^29.7.0",
|
|
26
25
|
"prettier": "^3.3.3",
|
|
27
26
|
"ts-jest": "^29.2.5",
|
|
28
|
-
"
|
|
27
|
+
"ts-node": "^10.9.2",
|
|
29
28
|
"tsconfig-paths": "^4.2.0",
|
|
30
29
|
"typescript": "~5.5.4",
|
|
31
|
-
"
|
|
30
|
+
"vite": "^5.4.8",
|
|
31
|
+
"@milaboratories/platforma-build-configs": "1.0.1",
|
|
32
|
+
"@platforma-sdk/oclif-index": "1.0.0"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@oclif/core": "^4.0.23",
|
|
@@ -42,13 +43,17 @@
|
|
|
42
43
|
},
|
|
43
44
|
"oclif": {
|
|
44
45
|
"bin": "pl-service",
|
|
45
|
-
"commands":
|
|
46
|
+
"commands": {
|
|
47
|
+
"strategy": "explicit",
|
|
48
|
+
"target": "./dist/index.js",
|
|
49
|
+
"identifier": "COMMANDS"
|
|
50
|
+
},
|
|
46
51
|
"dirname": "pl-service",
|
|
47
52
|
"topicSeparator": " "
|
|
48
53
|
},
|
|
49
54
|
"scripts": {
|
|
50
55
|
"type-check": "tsc --noEmit --composite false",
|
|
51
|
-
"build": "vite build",
|
|
56
|
+
"build": "oclif-index && vite build",
|
|
52
57
|
"test": "jest --passWithNoTests"
|
|
53
58
|
}
|
|
54
59
|
}
|
package/src/block.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import fs, { createWriteStream } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import winston from 'winston';
|
|
4
|
-
import { Writable, Transform } from 'node:stream';
|
|
5
|
-
import os from 'os';
|
|
6
|
-
import readlineSync from 'readline-sync';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import decompress from 'decompress';
|
|
9
|
-
|
|
10
|
-
const CreateBlockOptions = z.object({
|
|
11
|
-
npmOrgName: z.string().min(1),
|
|
12
|
-
orgName: z.string().min(1),
|
|
13
|
-
blockName: z.string().min(1)
|
|
14
|
-
});
|
|
15
|
-
export type CreateBlockOptions = z.infer<typeof CreateBlockOptions>;
|
|
16
|
-
|
|
17
|
-
/** Creates a block by cloning block-boilerplate repository. */
|
|
18
|
-
export async function createBlock(logger: winston.Logger) {
|
|
19
|
-
const options = askForOptions();
|
|
20
|
-
const targetPath = path.join(process.cwd(), options.blockName);
|
|
21
|
-
|
|
22
|
-
logger.info(`Downloading boilerplate code...`);
|
|
23
|
-
await downloadAndUnzip(
|
|
24
|
-
'https://github.com/milaboratory/platforma-block-boilerplate/archive/refs/heads/main.zip',
|
|
25
|
-
'platforma-block-boilerplate-main',
|
|
26
|
-
targetPath
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
logger.info(`Replace everything in the template with provided options...`);
|
|
30
|
-
replaceInAllFiles(
|
|
31
|
-
targetPath,
|
|
32
|
-
/pl-open\/my-org.block-boilerplate/g,
|
|
33
|
-
`${options.npmOrgName}/${options.orgName}.${options.blockName}`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function askForOptions(): CreateBlockOptions {
|
|
38
|
-
let npmOrgName = readlineSync.question('Write an organization name for npm. Default is "pl-open": ');
|
|
39
|
-
if (npmOrgName === '') {
|
|
40
|
-
npmOrgName = 'pl-open';
|
|
41
|
-
}
|
|
42
|
-
const orgName = readlineSync.question('Write an organization name, e.g. "my-org": ');
|
|
43
|
-
const blockName = readlineSync.question('Write a name of the block, e.g. "hello-world": ');
|
|
44
|
-
|
|
45
|
-
return CreateBlockOptions.parse({ npmOrgName, orgName, blockName });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function downloadAndUnzip(url: string, pathInArchive: string, outputPath: string) {
|
|
49
|
-
const response = await fetch(url);
|
|
50
|
-
const content = await response.blob();
|
|
51
|
-
|
|
52
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'create-repo'));
|
|
53
|
-
|
|
54
|
-
const tmpFile = path.join(tmpDir, 'packed-repo.zip');
|
|
55
|
-
const f = Writable.toWeb(createWriteStream(tmpFile));
|
|
56
|
-
await content.stream().pipeTo(f);
|
|
57
|
-
|
|
58
|
-
const tmpRepo = path.join(tmpDir, 'unpacked-repo');
|
|
59
|
-
fs.mkdirSync(tmpRepo);
|
|
60
|
-
await decompress(tmpFile, tmpRepo);
|
|
61
|
-
|
|
62
|
-
fs.cpSync(path.join(tmpRepo, pathInArchive), outputPath, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function replaceInAllFiles(dir: string, from: RegExp, to: string) {
|
|
66
|
-
getAllFiles(dir).forEach((fPath) => replaceInFile(fPath, from, to));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function getAllFiles(dir: string): string[] {
|
|
70
|
-
const allDirents = fs.readdirSync(dir, {
|
|
71
|
-
withFileTypes: true,
|
|
72
|
-
recursive: true
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return allDirents.filter((f) => f.isFile()).map((f) => path.join(f.parentPath, f.name));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function replaceInFile(fPath: string, from: RegExp, to: string) {
|
|
79
|
-
const content = fs.readFileSync(fPath);
|
|
80
|
-
const newContent = content.toString().replaceAll(from, to);
|
|
81
|
-
fs.writeFileSync(fPath, newContent);
|
|
82
|
-
}
|
package/src/cmd-opts.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Flags } from '@oclif/core';
|
|
2
|
-
|
|
3
|
-
export const GlobalFlags = {
|
|
4
|
-
'log-level': Flags.string({
|
|
5
|
-
description: 'logging level',
|
|
6
|
-
default: 'info',
|
|
7
|
-
options: ['error', 'warn', 'info', 'debug'],
|
|
8
|
-
required: false
|
|
9
|
-
})
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const ImageFlag = {
|
|
13
|
-
image: Flags.string({
|
|
14
|
-
description: 'use custom docker image to run platforma'
|
|
15
|
-
})
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const VersionFlag = {
|
|
19
|
-
version: Flags.string({
|
|
20
|
-
description: 'use custom platforma release (official docker image or binary package)'
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const LicenseFlags = {
|
|
25
|
-
license: Flags.string({
|
|
26
|
-
description: 'pass a license code. The license can be got from "https://licensing.milaboratories.com".'
|
|
27
|
-
}),
|
|
28
|
-
'license-file': Flags.file({
|
|
29
|
-
exists: true,
|
|
30
|
-
description:
|
|
31
|
-
"specify a path to the file with a license. The license can be got from 'https://licensing.milaboratories.com'."
|
|
32
|
-
})
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const AddressesFlags = {
|
|
36
|
-
'grpc-port': Flags.integer({
|
|
37
|
-
description: "port that the platform's grpc server will listen, by default it's 6345",
|
|
38
|
-
default: 6345,
|
|
39
|
-
env: 'PLATFORMA_GRPC_PORT'
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
'monitoring-port': Flags.integer({
|
|
43
|
-
description: "port that the platform's monitoring server will listen, by default it's 9090",
|
|
44
|
-
default: 9090,
|
|
45
|
-
env: 'PLATFORMA_MONITORING_PORT'
|
|
46
|
-
}),
|
|
47
|
-
|
|
48
|
-
'debug-port': Flags.integer({
|
|
49
|
-
description: "port that the platform's debug server will listen, by default it's 9091",
|
|
50
|
-
default: 9091,
|
|
51
|
-
env: 'PLATFORMA_DEBUG_PORT'
|
|
52
|
-
})
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const S3AddressesFlags = {
|
|
56
|
-
's3-address-port': Flags.integer({
|
|
57
|
-
description: 'port that S3 will listen, default is 9000',
|
|
58
|
-
default: 9000,
|
|
59
|
-
env: 'PLATFORMA_S3_PORT'
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
's3-console-address-port': Flags.integer({
|
|
63
|
-
description: 'port that a console of S3 will listen, default is 9001',
|
|
64
|
-
default: 9001,
|
|
65
|
-
env: 'PLATFORMA_S3_CONSOLE_PORT'
|
|
66
|
-
})
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const StorageFlag = {
|
|
70
|
-
storage: Flags.string({
|
|
71
|
-
description: 'specify path on host to be used as storage for all Platforma Backend data'
|
|
72
|
-
})
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const PlLogFileFlag = {
|
|
76
|
-
['pl-log-file']: Flags.file({
|
|
77
|
-
description: 'specify path for Platforma Backend log file'
|
|
78
|
-
})
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const PlWorkdirFlag = {
|
|
82
|
-
['pl-workdir']: Flags.file({
|
|
83
|
-
description: 'specify working directory for Platforma Backend process'
|
|
84
|
-
})
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const PlBinaryFlag = {
|
|
88
|
-
['pl-binary']: Flags.file({
|
|
89
|
-
description: 'start given Platforma Backend binary instead of automatically downloaded version'
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const PlSourcesFlag = {
|
|
94
|
-
['pl-sources']: Flags.file({
|
|
95
|
-
description: 'path to pl repository root: build Platforma Backend from sources and start the resulting binary'
|
|
96
|
-
})
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export const ConfigFlag = {
|
|
100
|
-
config: Flags.string({
|
|
101
|
-
description: 'use custom Platforma Backend config'
|
|
102
|
-
})
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const StoragePrimaryPathFlag = {
|
|
106
|
-
'storage-primary': Flags.file({
|
|
107
|
-
description: "specify path on host to be used as 'primary' storage"
|
|
108
|
-
})
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const StorageWorkPathFlag = {
|
|
112
|
-
'storage-work': Flags.file({
|
|
113
|
-
description: "specify path on host to be used as 'work' storage"
|
|
114
|
-
})
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const StorageLibraryPathFlag = {
|
|
118
|
-
'storage-primary': Flags.file({
|
|
119
|
-
description: "specify path on host to be used as 'library' storage"
|
|
120
|
-
})
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const StoragePrimaryURLFlag = {
|
|
124
|
-
'storage-primary': Flags.string({
|
|
125
|
-
description:
|
|
126
|
-
"specify 'primary' storage destination URL.\n" +
|
|
127
|
-
'\tfile:/path/to/dir for directory on local FS\n' +
|
|
128
|
-
'\ts3://<bucket>/?region=<name> for real AWS bucket\n' +
|
|
129
|
-
'\ts3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n' +
|
|
130
|
-
'\ts3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https'
|
|
131
|
-
})
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const StorageLibraryURLFlag = {
|
|
135
|
-
'storage-library': Flags.string({
|
|
136
|
-
description:
|
|
137
|
-
"specify 'library' storage destination URL.\n" +
|
|
138
|
-
'\tfile:/path/to/dir for directory on local FS\n' +
|
|
139
|
-
'\ts3://<bucket>/?region=<name> for real AWS bucket\n' +
|
|
140
|
-
'\ts3e://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via http\n' +
|
|
141
|
-
'\ts3es://<endpoint>/<bucket>/?region=<name> for bucket behind custom endpoint via https'
|
|
142
|
-
})
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export const AuthEnabledFlag = {
|
|
146
|
-
'auth-enabled': Flags.boolean({
|
|
147
|
-
description: 'enable authorization'
|
|
148
|
-
})
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const HTPasswdFileFlag = {
|
|
152
|
-
'auth-htpasswd-file': Flags.file({
|
|
153
|
-
description: 'path to .htpasswd file with Platforma users (static user DB auth source)'
|
|
154
|
-
})
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export const LDAPAddressFlag = {
|
|
158
|
-
'auth-ldap-server': Flags.string({
|
|
159
|
-
description: 'address of LDAP server to use for auth in Platforma (auth source)'
|
|
160
|
-
})
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export const LDAPDefaultDNFlag = {
|
|
164
|
-
'auth-ldap-default-dn': Flags.string({
|
|
165
|
-
description: 'DN to use when checking user with LDAP bind operation: e.g. cn=%u,ou=users,dc=example,dc=com'
|
|
166
|
-
})
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export const AuthFlags = {
|
|
170
|
-
...AuthEnabledFlag,
|
|
171
|
-
...HTPasswdFileFlag,
|
|
172
|
-
|
|
173
|
-
...LDAPAddressFlag,
|
|
174
|
-
...LDAPDefaultDNFlag
|
|
175
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import * as cmdOpts from '../cmd-opts';
|
|
3
|
-
import * as util from '../util';
|
|
4
|
-
import * as block from '../block';
|
|
5
|
-
|
|
6
|
-
export default class CreateBlock extends Command {
|
|
7
|
-
static override description = "Helps to create a new block by downloading a block's template.";
|
|
8
|
-
|
|
9
|
-
static override examples = ['<%= name %>'];
|
|
10
|
-
|
|
11
|
-
static override flags = {
|
|
12
|
-
...cmdOpts.GlobalFlags
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
public async run(): Promise<void> {
|
|
16
|
-
const { flags } = await this.parse(CreateBlock);
|
|
17
|
-
const logger = util.createLogger(flags['log-level']);
|
|
18
|
-
|
|
19
|
-
await block.createBlock(logger);
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/commands/reset.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import Core from '../core';
|
|
3
|
-
import * as cmdOpts from '../cmd-opts';
|
|
4
|
-
import * as util from '../util';
|
|
5
|
-
|
|
6
|
-
export default class Reset extends Command {
|
|
7
|
-
static override description =
|
|
8
|
-
'Clear service state (forget last run command, destroy docker services, volumes and so on)';
|
|
9
|
-
|
|
10
|
-
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
|
11
|
-
|
|
12
|
-
static override flags = {
|
|
13
|
-
...cmdOpts.GlobalFlags
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
public async run(): Promise<void> {
|
|
17
|
-
const { flags } = await this.parse(Reset);
|
|
18
|
-
|
|
19
|
-
const logger = util.createLogger(flags['log-level']);
|
|
20
|
-
const core = new Core(logger);
|
|
21
|
-
core.cleanup();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
import { Command } from '@oclif/core';
|
|
4
|
-
import Core from '../../../core';
|
|
5
|
-
import * as cmdOpts from '../../../cmd-opts';
|
|
6
|
-
import * as util from '../../../util';
|
|
7
|
-
import * as types from '../../../templates/types';
|
|
8
|
-
import state from '../../../state';
|
|
9
|
-
|
|
10
|
-
export default class S3 extends Command {
|
|
11
|
-
static override description = "Run platforma backend service with 'S3' primary storage type";
|
|
12
|
-
|
|
13
|
-
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
|
-
|
|
15
|
-
static override flags = {
|
|
16
|
-
...cmdOpts.GlobalFlags,
|
|
17
|
-
|
|
18
|
-
...cmdOpts.AddressesFlags,
|
|
19
|
-
...cmdOpts.ImageFlag,
|
|
20
|
-
...cmdOpts.VersionFlag,
|
|
21
|
-
|
|
22
|
-
...cmdOpts.StorageFlag,
|
|
23
|
-
|
|
24
|
-
...cmdOpts.LicenseFlags,
|
|
25
|
-
...cmdOpts.AuthFlags
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
public async run(): Promise<void> {
|
|
29
|
-
const { flags } = await this.parse(S3);
|
|
30
|
-
|
|
31
|
-
const logger = util.createLogger(flags['log-level']);
|
|
32
|
-
const core = new Core(logger);
|
|
33
|
-
core.mergeLicenseEnvs(flags);
|
|
34
|
-
|
|
35
|
-
const authEnabled = flags['auth-enabled'];
|
|
36
|
-
const authOptions: types.authOptions | undefined = authEnabled
|
|
37
|
-
? {
|
|
38
|
-
enabled: authEnabled,
|
|
39
|
-
drivers: core.initAuthDriversList(flags, '.')
|
|
40
|
-
}
|
|
41
|
-
: undefined;
|
|
42
|
-
|
|
43
|
-
const storage = flags.storage ? path.join('.', flags.storage) : state.path('data', 'docker-s3');
|
|
44
|
-
|
|
45
|
-
core.startDockerS3(storage, {
|
|
46
|
-
image: flags.image,
|
|
47
|
-
version: flags.version,
|
|
48
|
-
|
|
49
|
-
license: flags['license'],
|
|
50
|
-
licenseFile: flags['license-file'],
|
|
51
|
-
|
|
52
|
-
auth: authOptions,
|
|
53
|
-
|
|
54
|
-
'grpc-port': flags['grpc-port'],
|
|
55
|
-
'debug-port': flags['debug-port'],
|
|
56
|
-
'monitoring-port': flags['monitoring-port']
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
import { Command } from '@oclif/core';
|
|
4
|
-
import Core from '../../core';
|
|
5
|
-
import * as cmdOpts from '../../cmd-opts';
|
|
6
|
-
import * as util from '../../util';
|
|
7
|
-
import * as types from '../../templates/types';
|
|
8
|
-
import state from '../../state';
|
|
9
|
-
|
|
10
|
-
export default class Docker extends Command {
|
|
11
|
-
static override description = "Run platforma backend service with 'FS' primary storage type";
|
|
12
|
-
|
|
13
|
-
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
|
-
|
|
15
|
-
static override flags = {
|
|
16
|
-
...cmdOpts.GlobalFlags,
|
|
17
|
-
|
|
18
|
-
...cmdOpts.AddressesFlags,
|
|
19
|
-
...cmdOpts.ImageFlag,
|
|
20
|
-
...cmdOpts.VersionFlag,
|
|
21
|
-
|
|
22
|
-
...cmdOpts.AuthFlags,
|
|
23
|
-
...cmdOpts.LicenseFlags,
|
|
24
|
-
|
|
25
|
-
...cmdOpts.StorageFlag,
|
|
26
|
-
...cmdOpts.StoragePrimaryURLFlag,
|
|
27
|
-
...cmdOpts.StorageWorkPathFlag,
|
|
28
|
-
...cmdOpts.StorageLibraryURLFlag
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
public async run(): Promise<void> {
|
|
32
|
-
const { flags } = await this.parse(Docker);
|
|
33
|
-
|
|
34
|
-
const logger = util.createLogger(flags['log-level']);
|
|
35
|
-
const core = new Core(logger);
|
|
36
|
-
core.mergeLicenseEnvs(flags);
|
|
37
|
-
|
|
38
|
-
const authEnabled = flags['auth-enabled'];
|
|
39
|
-
const authOptions: types.authOptions | undefined = authEnabled
|
|
40
|
-
? {
|
|
41
|
-
enabled: authEnabled,
|
|
42
|
-
drivers: core.initAuthDriversList(flags, '.')
|
|
43
|
-
}
|
|
44
|
-
: undefined;
|
|
45
|
-
const storage = flags.storage ? path.join('.', flags.storage) : state.path('data', 'docker');
|
|
46
|
-
|
|
47
|
-
core.startDocker(storage, {
|
|
48
|
-
primaryStorageURL: flags['storage-primary'],
|
|
49
|
-
workStoragePath: flags['storage-work'],
|
|
50
|
-
libraryStorageURL: flags['storage-library'],
|
|
51
|
-
|
|
52
|
-
image: flags.image,
|
|
53
|
-
version: flags.version,
|
|
54
|
-
|
|
55
|
-
license: flags['license'],
|
|
56
|
-
licenseFile: flags['license-file'],
|
|
57
|
-
|
|
58
|
-
auth: authOptions,
|
|
59
|
-
|
|
60
|
-
'grpc-port': flags['grpc-port'],
|
|
61
|
-
'debug-port': flags['debug-port'],
|
|
62
|
-
'monitoring-port': flags['monitoring-port']
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
import { Command } from '@oclif/core';
|
|
4
|
-
import Core, { startLocalS3Options } from '../../../core';
|
|
5
|
-
import * as cmdOpts from '../../../cmd-opts';
|
|
6
|
-
import * as platforma from '../../../platforma';
|
|
7
|
-
import * as util from '../../../util';
|
|
8
|
-
import state from '../../../state';
|
|
9
|
-
|
|
10
|
-
export default class S3 extends Command {
|
|
11
|
-
static override description = 'Run Platforma Backend service as local process on current host (no docker container)';
|
|
12
|
-
|
|
13
|
-
static override examples = ['<%= config.bin %> <%= command.id %>'];
|
|
14
|
-
|
|
15
|
-
static override flags = {
|
|
16
|
-
...cmdOpts.GlobalFlags,
|
|
17
|
-
...cmdOpts.VersionFlag,
|
|
18
|
-
|
|
19
|
-
...cmdOpts.AddressesFlags,
|
|
20
|
-
...cmdOpts.S3AddressesFlags,
|
|
21
|
-
...cmdOpts.PlBinaryFlag,
|
|
22
|
-
...cmdOpts.PlSourcesFlag,
|
|
23
|
-
|
|
24
|
-
...cmdOpts.ConfigFlag,
|
|
25
|
-
|
|
26
|
-
...cmdOpts.LicenseFlags,
|
|
27
|
-
|
|
28
|
-
...cmdOpts.StorageFlag,
|
|
29
|
-
...cmdOpts.StoragePrimaryURLFlag,
|
|
30
|
-
...cmdOpts.StorageWorkPathFlag,
|
|
31
|
-
...cmdOpts.StorageLibraryURLFlag,
|
|
32
|
-
|
|
33
|
-
...cmdOpts.PlLogFileFlag,
|
|
34
|
-
...cmdOpts.PlWorkdirFlag,
|
|
35
|
-
...cmdOpts.AuthFlags
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
public async run(): Promise<void> {
|
|
39
|
-
const { flags } = await this.parse(S3);
|
|
40
|
-
|
|
41
|
-
const logger = util.createLogger(flags['log-level']);
|
|
42
|
-
const core = new Core(logger);
|
|
43
|
-
core.mergeLicenseEnvs(flags);
|
|
44
|
-
|
|
45
|
-
const workdir = flags['pl-workdir'] ?? '.';
|
|
46
|
-
const storage = flags.storage ? path.join(workdir, flags.storage) : state.path('data', 'local-s3');
|
|
47
|
-
const logFile = flags['pl-log-file'] ? path.join(workdir, flags['pl-log-file']) : undefined;
|
|
48
|
-
|
|
49
|
-
const authDrivers = core.initAuthDriversList(flags, workdir);
|
|
50
|
-
const authEnabled = flags['auth-enabled'] ?? authDrivers !== undefined;
|
|
51
|
-
|
|
52
|
-
var binaryPath = flags['pl-binary'];
|
|
53
|
-
if (flags['pl-sources']) {
|
|
54
|
-
binaryPath = core.buildPlatforma({ repoRoot: flags['pl-sources'] });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const startOptions: startLocalS3Options = {
|
|
58
|
-
binaryPath: binaryPath,
|
|
59
|
-
version: flags.version,
|
|
60
|
-
configPath: flags.config,
|
|
61
|
-
workdir: flags['pl-workdir'],
|
|
62
|
-
|
|
63
|
-
primaryURL: flags['storage-primary'],
|
|
64
|
-
libraryURL: flags['storage-library'],
|
|
65
|
-
|
|
66
|
-
minioPort: flags['s3-address-port'],
|
|
67
|
-
minioConsolePort: flags['s3-console-address-port'],
|
|
68
|
-
|
|
69
|
-
configOptions: {
|
|
70
|
-
grpc: { listen: `127.0.0.1:${flags['grpc-port']}` },
|
|
71
|
-
monitoring: { listen: `127.0.0.1:${flags['monitoring-port']}` },
|
|
72
|
-
debug: { listen: `127.0.0.1:${flags['debug-port']}` },
|
|
73
|
-
license: { value: flags['license'], file: flags['license-file'] },
|
|
74
|
-
log: { path: logFile },
|
|
75
|
-
localRoot: storage,
|
|
76
|
-
core: {
|
|
77
|
-
auth: { enabled: authEnabled, drivers: authDrivers }
|
|
78
|
-
},
|
|
79
|
-
storages: {
|
|
80
|
-
work: { type: 'FS', rootPath: flags['storage-work'] }
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
if (startOptions.binaryPath) {
|
|
86
|
-
core.startLocalS3(startOptions);
|
|
87
|
-
} else {
|
|
88
|
-
platforma
|
|
89
|
-
.getBinary(logger, { version: flags.version })
|
|
90
|
-
.then(() => core.startLocalS3(startOptions))
|
|
91
|
-
.catch(function (err: Error) {
|
|
92
|
-
logger.error(err.message);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|