ztechno_core 0.0.101 → 0.0.103

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
@@ -9,5 +9,6 @@ export * from './typings';
9
9
  export * from './scripts/docker-update';
10
10
  export * from './scripts/docker-build';
11
11
  export * from './scripts/docker-push';
12
+ export * from './scripts/docker-publish';
12
13
  export * from './schema';
13
14
  export { ZEngineBase, ZCryptoService, ZMailService, ZSQLService, ZTranslateService, ZUserService };
package/lib/index.js CHANGED
@@ -91,5 +91,6 @@ __exportStar(require('./typings'), exports);
91
91
  __exportStar(require('./scripts/docker-update'), exports);
92
92
  __exportStar(require('./scripts/docker-build'), exports);
93
93
  __exportStar(require('./scripts/docker-push'), exports);
94
+ __exportStar(require('./scripts/docker-publish'), exports);
94
95
  // Re-export all schema-related modules
95
96
  __exportStar(require('./schema'), exports);
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Run the full Docker publish pipeline: build → push → update
4
+ * All options are auto-detected from package.json and .env
5
+ * @param opt.packagename - Override the image name
6
+ * @param opt.awsAccountId - Override the AWS Account ID
7
+ * @param opt.tag - Override the tag (defaults to "latest")
8
+ * @param opt.context - Docker build context path (defaults to ".")
9
+ * @param opt.port - Override the port for remote update
10
+ * @param opt.volumes - Override volumes for remote update
11
+ */
12
+ export declare function dockerPublish(opt?: {
13
+ packagename?: string;
14
+ awsAccountId?: string;
15
+ tag?: string;
16
+ context?: string;
17
+ port?: string | number;
18
+ volumes?: string[];
19
+ }): Promise<void>;
@@ -0,0 +1,114 @@
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.dockerPublish = void 0;
10
+ const path_1 = __importDefault(require('path'));
11
+ const fs_1 = __importDefault(require('fs'));
12
+ const dotenv_1 = require('dotenv');
13
+ const docker_build_1 = require('./docker-build');
14
+ const docker_push_1 = require('./docker-push');
15
+ const docker_update_1 = require('./docker-update');
16
+ // ANSI color helpers
17
+ const red = (msg) => `\x1b[31m${msg}\x1b[0m`;
18
+ const green = (msg) => `\x1b[32m${msg}\x1b[0m`;
19
+ const cyan = (msg) => `\x1b[36m${msg}\x1b[0m`;
20
+ function loadPackageJson() {
21
+ const pkgPath = path_1.default.join(process.cwd(), 'package.json');
22
+ if (!fs_1.default.existsSync(pkgPath)) {
23
+ throw new Error(`No package.json found in ${process.cwd()}`);
24
+ }
25
+ return JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf-8'));
26
+ }
27
+ /**
28
+ * Run the full Docker publish pipeline: build → push → update
29
+ * All options are auto-detected from package.json and .env
30
+ * @param opt.packagename - Override the image name
31
+ * @param opt.awsAccountId - Override the AWS Account ID
32
+ * @param opt.tag - Override the tag (defaults to "latest")
33
+ * @param opt.context - Docker build context path (defaults to ".")
34
+ * @param opt.port - Override the port for remote update
35
+ * @param opt.volumes - Override volumes for remote update
36
+ */
37
+ async function dockerPublish(opt) {
38
+ // Load .env so ZTECHNO_API_SECRET (and other vars) are available
39
+ (0, dotenv_1.config)({ path: path_1.default.join(process.cwd(), '.env') });
40
+ const pkg = loadPackageJson();
41
+ const packagename = opt?.packagename || pkg.name;
42
+ const awsAccountId = opt?.awsAccountId || pkg.config?.awsAccountId || process.env.AWS_ACCOUNT_ID;
43
+ const tag = opt?.tag || 'latest';
44
+ console.log(cyan(`\n[Docker Publish Pipeline]`));
45
+ console.log(cyan(` Image: ${awsAccountId}/${packagename}:${tag}\n`));
46
+ // Step 1: Build
47
+ console.log(cyan(`── Step 1/3: Build ──`));
48
+ (0, docker_build_1.dockerBuild)({ packagename, awsAccountId, tag, context: opt?.context });
49
+ // Step 2: Push
50
+ console.log(cyan(`\n── Step 2/3: Push ──`));
51
+ (0, docker_push_1.dockerPush)({ packagename, awsAccountId, tag });
52
+ // Step 3: Update remote
53
+ console.log(cyan(`\n── Step 3/3: Update Remote ──`));
54
+ const port = opt?.port || pkg.config?.port;
55
+ let volumes = opt?.volumes;
56
+ if (!volumes && pkg.config?.volumes) {
57
+ volumes = Array.isArray(pkg.config.volumes) ? pkg.config.volumes : pkg.config.volumes.split(',').filter(Boolean);
58
+ }
59
+ if (!port) {
60
+ console.log(green(`✓ Build & push complete. Skipping remote update (no port configured).`));
61
+ return;
62
+ }
63
+ await (0, docker_update_1.updateDocker)({
64
+ packagename: packagename,
65
+ port,
66
+ volumes,
67
+ c: console,
68
+ });
69
+ console.log(green(`\n✓ Publish pipeline complete!`));
70
+ }
71
+ exports.dockerPublish = dockerPublish;
72
+ const USAGE = `
73
+ Usage:
74
+ ztechno-docker-publish [options]
75
+
76
+ Runs: docker build → docker push → remote update
77
+
78
+ Options:
79
+ --name <name> Override image name (default: package.json "name")
80
+ --account <id> Override AWS Account ID (default: package.json "config.awsAccountId")
81
+ --tag <tag> Override tag (default: "latest")
82
+ --context <path> Docker build context (default: ".")
83
+ -h, --help Show this help
84
+
85
+ package.json format:
86
+ {
87
+ "name": "my-image",
88
+ "config": {
89
+ "awsAccountId": "00028463827",
90
+ "port": 3000,
91
+ "volumes": ["/data:/app/data"]
92
+ }
93
+ }
94
+ `.trim();
95
+ if (require.main === module) {
96
+ const args = process.argv.slice(2);
97
+ if (args.includes('--help') || args.includes('-h')) {
98
+ console.log(USAGE);
99
+ process.exit(0);
100
+ }
101
+ const getArg = (flag) => {
102
+ const idx = args.indexOf(flag);
103
+ return idx !== -1 && idx + 1 < args.length ? args[idx + 1] : undefined;
104
+ };
105
+ dockerPublish({
106
+ packagename: getArg('--name'),
107
+ awsAccountId: getArg('--account'),
108
+ tag: getArg('--tag'),
109
+ context: getArg('--context'),
110
+ }).catch((err) => {
111
+ console.error(red(`✗ Error: ${err.message}`));
112
+ process.exit(1);
113
+ });
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.101",
3
+ "version": "0.0.103",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,7 +23,8 @@
23
23
  "bin": {
24
24
  "ztechno-docker-update": "lib/scripts/docker-update.js",
25
25
  "ztechno-docker-build": "lib/scripts/docker-build.js",
26
- "ztechno-docker-push": "lib/scripts/docker-push.js"
26
+ "ztechno-docker-push": "lib/scripts/docker-push.js",
27
+ "ztechno-docker-publish": "lib/scripts/docker-publish.js"
27
28
  },
28
29
  "keywords": [
29
30
  "ztechno",