ztechno_core 0.0.100 → 0.0.101

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/lib/index.d.ts CHANGED
@@ -7,5 +7,7 @@ import { ZUserService } from './user_service';
7
7
  export { middleware } from './express';
8
8
  export * from './typings';
9
9
  export * from './scripts/docker-update';
10
+ export * from './scripts/docker-build';
11
+ export * from './scripts/docker-push';
10
12
  export * from './schema';
11
13
  export { ZEngineBase, ZCryptoService, ZMailService, ZSQLService, ZTranslateService, ZUserService };
package/lib/index.js CHANGED
@@ -89,5 +89,7 @@ Object.defineProperty(exports, 'middleware', {
89
89
  __exportStar(require('./typings'), exports);
90
90
  // Re-export specific scripts
91
91
  __exportStar(require('./scripts/docker-update'), exports);
92
+ __exportStar(require('./scripts/docker-build'), exports);
93
+ __exportStar(require('./scripts/docker-push'), exports);
92
94
  // Re-export all schema-related modules
93
95
  __exportStar(require('./schema'), exports);
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Build a Docker image tagged as <awsAccountId>/<packagename>:latest
4
+ * @param opt.packagename - Override the image name (defaults to package.json name)
5
+ * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
6
+ * @param opt.tag - Override the tag (defaults to "latest")
7
+ * @param opt.context - Docker build context path (defaults to ".")
8
+ */
9
+ export declare function dockerBuild(opt?: {
10
+ packagename?: string;
11
+ awsAccountId?: string;
12
+ tag?: string;
13
+ context?: string;
14
+ }): void;
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ var __importDefault =
4
+ (this && this.__importDefault) ||
5
+ function (mod) {
6
+ return mod && mod.__esModule ? mod : { default: mod };
7
+ };
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+ exports.dockerBuild = void 0;
10
+ const child_process_1 = require('child_process');
11
+ const path_1 = __importDefault(require('path'));
12
+ const fs_1 = __importDefault(require('fs'));
13
+ // ANSI color helpers
14
+ const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
15
+ const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
16
+ const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
17
+ function loadPackageJson() {
18
+ const pkgPath = path_1.default.join(process.cwd(), 'package.json');
19
+ if (!fs_1.default.existsSync(pkgPath)) {
20
+ throw new Error(`No package.json found in ${process.cwd()}`);
21
+ }
22
+ return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
23
+ }
24
+ /**
25
+ * Build a Docker image tagged as <awsAccountId>/<packagename>:latest
26
+ * @param opt.packagename - Override the image name (defaults to package.json name)
27
+ * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
28
+ * @param opt.tag - Override the tag (defaults to "latest")
29
+ * @param opt.context - Docker build context path (defaults to ".")
30
+ */
31
+ function dockerBuild(opt) {
32
+ const pkg = loadPackageJson();
33
+ const packagename = opt?.packagename || pkg.name;
34
+ const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
35
+ const tag = opt?.tag || 'latest';
36
+ const context = opt?.context || '.';
37
+ if (!packagename) {
38
+ throw new Error('Missing package name. Set "name" in package.json or pass --name.');
39
+ }
40
+ if (!awsAccountId) {
41
+ throw new Error('Missing AWS Account ID. Set "config.awsAccountId" in package.json or AWS_ACCOUNT_ID env var.');
42
+ }
43
+ const image = `${awsAccountId}/${packagename}:${tag}`;
44
+ const cmd = `docker build -t ${image} ${context}`;
45
+ console.log(green(`[Docker Build]`));
46
+ console.log(cyan(`> ${cmd}`));
47
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
48
+ console.log(green(`✓ Built ${image}`));
49
+ }
50
+ exports.dockerBuild = dockerBuild;
51
+ const USAGE = `
52
+ Usage:
53
+ ztechno-docker-build [options]
54
+
55
+ Options:
56
+ --name <name> Override image name (default: package.json "name")
57
+ --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
58
+ --tag <tag> Override tag (default: "latest")
59
+ --context <path> Docker build context (default: ".")
60
+ -h, --help Show this help
61
+
62
+ package.json format:
63
+ {
64
+ "name": "my-image",
65
+ "config": {
66
+ "awsAccountId": "00028463827"
67
+ }
68
+ }
69
+ `.trim();
70
+ if (require.main === module) {
71
+ try {
72
+ const args = process.argv.slice(2);
73
+ if (args.includes('--help') || args.includes('-h')) {
74
+ console.log(USAGE);
75
+ process.exit(0);
76
+ }
77
+ const getArg = (flag) => {
78
+ const idx = args.indexOf(flag);
79
+ return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
80
+ };
81
+ dockerBuild({
82
+ packagename: getArg('--name'),
83
+ awsAccountId: getArg('--account'),
84
+ tag: getArg('--tag'),
85
+ context: getArg('--context'),
86
+ });
87
+ } catch (err) {
88
+ console.error(red(`✗ Error: ${err.message}`));
89
+ process.exit(1);
90
+ }
91
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Push a Docker image tagged as <awsAccountId>/<packagename>:latest
4
+ * @param opt.packagename - Override the image name (defaults to package.json name)
5
+ * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
6
+ * @param opt.tag - Override the tag (defaults to "latest")
7
+ */
8
+ export declare function dockerPush(opt?: { packagename?: string; awsAccountId?: string; tag?: string }): void;
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ var __importDefault =
4
+ (this && this.__importDefault) ||
5
+ function (mod) {
6
+ return mod && mod.__esModule ? mod : { default: mod };
7
+ };
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+ exports.dockerPush = void 0;
10
+ const child_process_1 = require('child_process');
11
+ const path_1 = __importDefault(require('path'));
12
+ const fs_1 = __importDefault(require('fs'));
13
+ // ANSI color helpers
14
+ const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
15
+ const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
16
+ const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
17
+ function loadPackageJson() {
18
+ const pkgPath = path_1.default.join(process.cwd(), 'package.json');
19
+ if (!fs_1.default.existsSync(pkgPath)) {
20
+ throw new Error(`No package.json found in ${process.cwd()}`);
21
+ }
22
+ return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
23
+ }
24
+ /**
25
+ * Push a Docker image tagged as <awsAccountId>/<packagename>:latest
26
+ * @param opt.packagename - Override the image name (defaults to package.json name)
27
+ * @param opt.awsAccountId - Override the AWS Account ID (defaults to package.json config.awsAccountId)
28
+ * @param opt.tag - Override the tag (defaults to "latest")
29
+ */
30
+ function dockerPush(opt) {
31
+ const pkg = loadPackageJson();
32
+ const packagename = opt?.packagename || pkg.name;
33
+ const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
34
+ const tag = opt?.tag || 'latest';
35
+ if (!packagename) {
36
+ throw new Error('Missing package name. Set "name" in package.json or pass --name.');
37
+ }
38
+ if (!awsAccountId) {
39
+ throw new Error('Missing AWS Account ID. Set "config.awsAccountId" in package.json or AWS_ACCOUNT_ID env var.');
40
+ }
41
+ const image = `${awsAccountId}/${packagename}:${tag}`;
42
+ const cmd = `docker push ${image}`;
43
+ console.log(green(`[Docker Push]`));
44
+ console.log(cyan(`> ${cmd}`));
45
+ (0, child_process_1.execSync)(cmd, { stdio: 'inherit' });
46
+ console.log(green(`✓ Pushed ${image}`));
47
+ }
48
+ exports.dockerPush = dockerPush;
49
+ const USAGE = `
50
+ Usage:
51
+ ztechno-docker-push [options]
52
+
53
+ Options:
54
+ --name <name> Override image name (default: package.json "name")
55
+ --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
56
+ --tag <tag> Override tag (default: "latest")
57
+ -h, --help Show this help
58
+
59
+ package.json format:
60
+ {
61
+ "name": "my-image",
62
+ "config": {
63
+ "awsAccountId": "00028463827"
64
+ }
65
+ }
66
+ `.trim();
67
+ if (require.main === module) {
68
+ try {
69
+ const args = process.argv.slice(2);
70
+ if (args.includes('--help') || args.includes('-h')) {
71
+ console.log(USAGE);
72
+ process.exit(0);
73
+ }
74
+ const getArg = (flag) => {
75
+ const idx = args.indexOf(flag);
76
+ return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
77
+ };
78
+ dockerPush({
79
+ packagename: getArg('--name'),
80
+ awsAccountId: getArg('--account'),
81
+ tag: getArg('--tag'),
82
+ });
83
+ } catch (err) {
84
+ console.error(red(`✗ Error: ${err.message}`));
85
+ process.exit(1);
86
+ }
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.100",
3
+ "version": "0.0.101",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,7 +21,9 @@
21
21
  "update": "npm run build && npm version patch && npm publish"
22
22
  },
23
23
  "bin": {
24
- "ztechno-docker-update": "lib/scripts/docker-update.js"
24
+ "ztechno-docker-update": "lib/scripts/docker-update.js",
25
+ "ztechno-docker-build": "lib/scripts/docker-build.js",
26
+ "ztechno-docker-push": "lib/scripts/docker-push.js"
25
27
  },
26
28
  "keywords": [
27
29
  "ztechno",