dcdx 1.2.0-next.6 → 1.2.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.
Files changed (75) hide show
  1. package/assets/versions.json +1 -1
  2. package/lib/commands/build.js +8510 -1
  3. package/lib/commands/database.js +8441 -1
  4. package/lib/commands/debug.js +9257 -0
  5. package/lib/commands/profile.js +2 -1
  6. package/lib/commands/reset.js +9194 -1
  7. package/lib/commands/run.js +9227 -1
  8. package/lib/commands/stop.js +9191 -1
  9. package/lib/index.js +93 -1
  10. package/lib/types/src/applications/bamboo.d.ts +4 -6
  11. package/lib/types/src/applications/base.d.ts +8 -12
  12. package/lib/types/src/applications/bitbucket.d.ts +4 -6
  13. package/lib/types/src/applications/confluence.d.ts +4 -6
  14. package/lib/types/src/applications/jira.d.ts +4 -6
  15. package/lib/types/src/databases/base.d.ts +7 -15
  16. package/lib/types/src/databases/mssql.d.ts +3 -12
  17. package/lib/types/src/databases/mysql.d.ts +3 -12
  18. package/lib/types/src/databases/postgres.d.ts +3 -12
  19. package/lib/types/src/helpers/ActionHandler.d.ts +39 -0
  20. package/lib/types/src/helpers/FileWatcher.d.ts +3 -0
  21. package/lib/types/src/helpers/amps.d.ts +22 -12
  22. package/lib/types/src/helpers/docker.d.ts +3 -5
  23. package/lib/types/src/helpers/getApplication.d.ts +2 -6
  24. package/lib/types/src/helpers/getDatabaseEngine.d.ts +2 -0
  25. package/lib/types/src/helpers/getZodDefaults.d.ts +3 -0
  26. package/lib/types/src/helpers/licences.d.ts +2 -2
  27. package/lib/types/src/helpers/showHelpWithDefaultCommandOptions.d.ts +2 -0
  28. package/lib/types/src/types/AMPS.d.ts +96 -0
  29. package/lib/types/src/types/Application.d.ts +65 -0
  30. package/lib/types/src/types/Database.d.ts +169 -0
  31. package/package.json +10 -5
  32. package/lib/commands/database/mssql.js +0 -2
  33. package/lib/commands/database/mysql.js +0 -2
  34. package/lib/commands/database/postgres.js +0 -2
  35. package/lib/commands/reset/bamboo.js +0 -2
  36. package/lib/commands/reset/bitbucket.js +0 -2
  37. package/lib/commands/reset/command.js +0 -2
  38. package/lib/commands/reset/confluence.js +0 -2
  39. package/lib/commands/reset/jira.js +0 -2
  40. package/lib/commands/run/bamboo.js +0 -2
  41. package/lib/commands/run/bitbucket.js +0 -2
  42. package/lib/commands/run/command.js +0 -2
  43. package/lib/commands/run/confluence.js +0 -2
  44. package/lib/commands/run/jira.js +0 -2
  45. package/lib/commands/start.js +0 -2
  46. package/lib/commands/stop/bamboo.js +0 -2
  47. package/lib/commands/stop/bitbucket.js +0 -2
  48. package/lib/commands/stop/command.js +0 -2
  49. package/lib/commands/stop/confluence.js +0 -2
  50. package/lib/commands/stop/jira.js +0 -2
  51. package/lib/types/src/commands/database/mysql.d.ts +0 -2
  52. package/lib/types/src/commands/database/postgres.d.ts +0 -2
  53. package/lib/types/src/commands/reset/bamboo.d.ts +0 -2
  54. package/lib/types/src/commands/reset/bitbucket.d.ts +0 -2
  55. package/lib/types/src/commands/reset/command.d.ts +0 -3
  56. package/lib/types/src/commands/reset/confluence.d.ts +0 -2
  57. package/lib/types/src/commands/reset/jira.d.ts +0 -2
  58. package/lib/types/src/commands/run/bamboo.d.ts +0 -2
  59. package/lib/types/src/commands/run/bitbucket.d.ts +0 -2
  60. package/lib/types/src/commands/run/command.d.ts +0 -3
  61. package/lib/types/src/commands/run/confluence.d.ts +0 -2
  62. package/lib/types/src/commands/run/jira.d.ts +0 -2
  63. package/lib/types/src/commands/start.d.ts +0 -2
  64. package/lib/types/src/commands/stop/bamboo.d.ts +0 -2
  65. package/lib/types/src/commands/stop/bitbucket.d.ts +0 -2
  66. package/lib/types/src/commands/stop/command.d.ts +0 -3
  67. package/lib/types/src/commands/stop/confluence.d.ts +0 -2
  68. package/lib/types/src/commands/stop/jira.d.ts +0 -2
  69. package/lib/types/src/types/ApplicationOptions.d.ts +0 -13
  70. package/lib/types/src/types/DatabaseEngine.d.ts +0 -17
  71. package/lib/types/src/types/DatabaseOptions.d.ts +0 -9
  72. package/lib/types/src/types/SupportedApplications.d.ts +0 -6
  73. package/lib/types/src/types/SupportedDatabaseDrivers.d.ts +0 -1
  74. package/lib/types/src/types/SupportedDatabaseEngines.d.ts +0 -1
  75. /package/lib/types/src/commands/{database/mssql.d.ts → debug.d.ts} +0 -0
@@ -0,0 +1,169 @@
1
+ import { z } from 'zod';
2
+ export interface DatabaseEngine {
3
+ url: string;
4
+ options: TDatabaseOptions;
5
+ start(clean?: boolean): Promise<void>;
6
+ stop(prune?: boolean): Promise<void>;
7
+ run(sql: string | {
8
+ query: string;
9
+ values: unknown[];
10
+ }): Promise<void>;
11
+ }
12
+ export declare const SupportedDatabaseEngines: z.ZodEnum<["postgresql", "mysql", "mssql"]>;
13
+ export declare const SupportedMSSQLEditions: z.ZodEnum<["Developer", "Express", "Standard", "Enterprise", "EnterpriseCore"]>;
14
+ export declare const DatabaseOptions: z.ZodObject<{
15
+ name: z.ZodEnum<["postgresql", "mysql", "mssql"]>;
16
+ port: z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>;
17
+ database: z.ZodDefault<z.ZodString>;
18
+ username: z.ZodDefault<z.ZodString>;
19
+ password: z.ZodDefault<z.ZodString>;
20
+ clean: z.ZodDefault<z.ZodBoolean>;
21
+ prune: z.ZodDefault<z.ZodBoolean>;
22
+ verbose: z.ZodDefault<z.ZodBoolean>;
23
+ driver: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ database: string;
26
+ name: "postgresql" | "mysql" | "mssql";
27
+ port: number;
28
+ username: string;
29
+ password: string;
30
+ clean: boolean;
31
+ prune: boolean;
32
+ verbose: boolean;
33
+ driver: string;
34
+ }, {
35
+ name: "postgresql" | "mysql" | "mssql";
36
+ port: string | number;
37
+ driver: string;
38
+ database?: string | undefined;
39
+ username?: string | undefined;
40
+ password?: string | undefined;
41
+ clean?: boolean | undefined;
42
+ prune?: boolean | undefined;
43
+ verbose?: boolean | undefined;
44
+ }>;
45
+ export declare const PostgreSQLOptions: z.ZodObject<z.objectUtil.extendShape<{
46
+ name: z.ZodEnum<["postgresql", "mysql", "mssql"]>;
47
+ port: z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>;
48
+ database: z.ZodDefault<z.ZodString>;
49
+ username: z.ZodDefault<z.ZodString>;
50
+ password: z.ZodDefault<z.ZodString>;
51
+ clean: z.ZodDefault<z.ZodBoolean>;
52
+ prune: z.ZodDefault<z.ZodBoolean>;
53
+ verbose: z.ZodDefault<z.ZodBoolean>;
54
+ driver: z.ZodString;
55
+ }, {
56
+ name: z.ZodDefault<z.ZodEffects<z.ZodEnum<["postgresql", "mysql", "mssql"]>, "postgresql" | "mysql" | "mssql", "postgresql" | "mysql" | "mssql">>;
57
+ tag: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
58
+ port: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>>;
59
+ driver: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
60
+ }>, "strip", z.ZodTypeAny, {
61
+ database: string;
62
+ name: "postgresql" | "mysql" | "mssql";
63
+ port: number;
64
+ username: string;
65
+ password: string;
66
+ clean: boolean;
67
+ prune: boolean;
68
+ verbose: boolean;
69
+ driver: string;
70
+ tag: string;
71
+ }, {
72
+ database?: string | undefined;
73
+ name?: "postgresql" | "mysql" | "mssql" | undefined;
74
+ port?: string | number | undefined;
75
+ username?: string | undefined;
76
+ password?: string | undefined;
77
+ clean?: boolean | undefined;
78
+ prune?: boolean | undefined;
79
+ verbose?: boolean | undefined;
80
+ driver?: string | undefined;
81
+ tag?: string | undefined;
82
+ }>;
83
+ export declare const MySQLOptions: z.ZodObject<z.objectUtil.extendShape<{
84
+ name: z.ZodEnum<["postgresql", "mysql", "mssql"]>;
85
+ port: z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>;
86
+ database: z.ZodDefault<z.ZodString>;
87
+ username: z.ZodDefault<z.ZodString>;
88
+ password: z.ZodDefault<z.ZodString>;
89
+ clean: z.ZodDefault<z.ZodBoolean>;
90
+ prune: z.ZodDefault<z.ZodBoolean>;
91
+ verbose: z.ZodDefault<z.ZodBoolean>;
92
+ driver: z.ZodString;
93
+ }, {
94
+ name: z.ZodDefault<z.ZodEffects<z.ZodEnum<["postgresql", "mysql", "mssql"]>, "postgresql" | "mysql" | "mssql", "postgresql" | "mysql" | "mssql">>;
95
+ tag: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
96
+ port: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>>;
97
+ driver: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
98
+ }>, "strip", z.ZodTypeAny, {
99
+ database: string;
100
+ name: "postgresql" | "mysql" | "mssql";
101
+ port: number;
102
+ username: string;
103
+ password: string;
104
+ clean: boolean;
105
+ prune: boolean;
106
+ verbose: boolean;
107
+ driver: string;
108
+ tag: string;
109
+ }, {
110
+ database?: string | undefined;
111
+ name?: "postgresql" | "mysql" | "mssql" | undefined;
112
+ port?: string | number | undefined;
113
+ username?: string | undefined;
114
+ password?: string | undefined;
115
+ clean?: boolean | undefined;
116
+ prune?: boolean | undefined;
117
+ verbose?: boolean | undefined;
118
+ driver?: string | undefined;
119
+ tag?: string | undefined;
120
+ }>;
121
+ export declare const MSSQLOptions: z.ZodObject<z.objectUtil.extendShape<{
122
+ name: z.ZodEnum<["postgresql", "mysql", "mssql"]>;
123
+ port: z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>;
124
+ database: z.ZodDefault<z.ZodString>;
125
+ username: z.ZodDefault<z.ZodString>;
126
+ password: z.ZodDefault<z.ZodString>;
127
+ clean: z.ZodDefault<z.ZodBoolean>;
128
+ prune: z.ZodDefault<z.ZodBoolean>;
129
+ verbose: z.ZodDefault<z.ZodBoolean>;
130
+ driver: z.ZodString;
131
+ }, {
132
+ name: z.ZodDefault<z.ZodEffects<z.ZodEnum<["postgresql", "mysql", "mssql"]>, "postgresql" | "mysql" | "mssql", "postgresql" | "mysql" | "mssql">>;
133
+ tag: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
134
+ edition: z.ZodDefault<z.ZodEnum<["Developer", "Express", "Standard", "Enterprise", "EnterpriseCore"]>>;
135
+ port: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodEffects<z.ZodEffects<z.ZodString, number, string>, number, string>]>>;
136
+ username: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
137
+ password: z.ZodDefault<z.ZodString>;
138
+ driver: z.ZodDefault<z.ZodEffects<z.ZodString, string, string>>;
139
+ }>, "strip", z.ZodTypeAny, {
140
+ database: string;
141
+ name: "postgresql" | "mysql" | "mssql";
142
+ port: number;
143
+ username: string;
144
+ password: string;
145
+ clean: boolean;
146
+ prune: boolean;
147
+ verbose: boolean;
148
+ driver: string;
149
+ tag: string;
150
+ edition: "Developer" | "Express" | "Standard" | "Enterprise" | "EnterpriseCore";
151
+ }, {
152
+ database?: string | undefined;
153
+ name?: "postgresql" | "mysql" | "mssql" | undefined;
154
+ port?: string | number | undefined;
155
+ username?: string | undefined;
156
+ password?: string | undefined;
157
+ clean?: boolean | undefined;
158
+ prune?: boolean | undefined;
159
+ verbose?: boolean | undefined;
160
+ driver?: string | undefined;
161
+ tag?: string | undefined;
162
+ edition?: "Developer" | "Express" | "Standard" | "Enterprise" | "EnterpriseCore" | undefined;
163
+ }>;
164
+ export type TDatabaseOptions = z.infer<typeof DatabaseOptions>;
165
+ export type TPostgreSQLOptions = z.infer<typeof PostgreSQLOptions>;
166
+ export type TMySQLOptions = z.infer<typeof MySQLOptions>;
167
+ export type TMSSQLOptions = z.infer<typeof MSSQLOptions>;
168
+ export type TSupportedDatabaseEngines = z.infer<typeof SupportedDatabaseEngines>;
169
+ export type TSupportedMSSQLEditions = z.infer<typeof SupportedMSSQLEditions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcdx",
3
- "version": "1.2.0-next.6",
3
+ "version": "1.2.0",
4
4
  "author": "Collabsoft <info@collabsoft.net>",
5
5
  "description": "The Unofficial CLI for Atlassian Data Center Plugin Development",
6
6
  "type": "module",
@@ -27,7 +27,9 @@
27
27
  "generate:versions": "node ./generateVersionList.mjs",
28
28
  "watch": "yarn run nodemon --watch src -e '.ts' --exec 'yarn build'",
29
29
  "start": "./lib/index.js",
30
- "prepack": "yarn generate:versions && yarn build"
30
+ "prepack": "yarn generate:versions && yarn build",
31
+ "test": "yarn run vitest --coverage --disable-console-intercept --watch=false --silent=false",
32
+ "test:ui": "yarn run vitest --coverage --disable-console-intercept --silent=false --ui"
31
33
  },
32
34
  "repository": {
33
35
  "type": "git",
@@ -49,9 +51,10 @@
49
51
  "@types/js-yaml": "4",
50
52
  "@types/node": "18.16.0",
51
53
  "@types/pg": "8",
52
- "@types/yargs": "17.0.32",
53
54
  "@typescript-eslint/eslint-plugin": "7.6.0",
54
55
  "@typescript-eslint/parser": "7.6.0",
56
+ "@vitest/coverage-v8": "^1.6.0",
57
+ "@vitest/ui": "^1.6.0",
55
58
  "eslint": "9.0.0",
56
59
  "eslint-plugin-simple-import-sort": "12.0.0",
57
60
  "nodemon": "3.1.0",
@@ -59,7 +62,9 @@
59
62
  "rollup-plugin-executable": "1.6.3",
60
63
  "semantic-release": "23.0.8",
61
64
  "typescript": "5.4.4",
62
- "typescript-eslint": "7.6.0"
65
+ "typescript-eslint": "7.6.0",
66
+ "vitest": "1.6.0",
67
+ "vitest-mock-process": "1.0.4"
63
68
  },
64
69
  "dependencies": {
65
70
  "@xmldom/xmldom": "0.8.10",
@@ -77,7 +82,7 @@
77
82
  "simple-git": "3.24.0",
78
83
  "tedious": "18.1.0",
79
84
  "xpath": "0.0.34",
80
- "yargs": "17.7.2"
85
+ "zod": "3.23.6"
81
86
  },
82
87
  "release": {
83
88
  "branches": [
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{program as u,Option as t}from"commander";import{gracefulExit as n,asyncExitHook as e}from"exit-hook";import{spawn as o}from"child_process";import{upAll as s}from"docker-compose";import{stop as a,downAll as i,ps as r}from"docker-compose/dist/v2.js";import b from"events";import{dump as C}from"js-yaml";import{cwd as U}from"process";import{Sequelize as c,ConnectionError as p,TimeoutError as d,ConnectionTimedOutError as l,ConnectionRefusedError as h,ConnectionAcquireTimeoutError as m}from"sequelize";var g=["2017-CU1-ubuntu","2017-CU10","2017-CU10-ubuntu","2017-CU11","2017-CU11-ubuntu","2017-CU12","2017-CU12-ubuntu","2017-CU13","2017-CU13-ubuntu","2017-CU14","2017-CU14-ubuntu","2017-CU15","2017-CU15-GDR","2017-CU15-GDR-ubuntu","2017-CU15-GDR1-ubuntu-16.04","2017-CU15-ubuntu","2017-CU16","2017-CU16-ubuntu","2017-CU17","2017-CU17-ubuntu","2017-CU18-ubuntu-16.04","2017-CU19-ubuntu-16.04","2017-CU2-ubuntu","2017-CU20","2017-CU20-ubuntu","2017-CU20-ubuntu-16.04","2017-CU21-ubuntu-16.04","2017-CU22-GDR1-ubuntu-16.04","2017-CU22-OD1-ubuntu-16.04","2017-CU22-ubuntu-16.04","2017-CU23-ubuntu-16.04","2017-CU24-ubuntu-16.04","2017-CU25-ubuntu-16.04","2017-CU26-ubuntu-16.04","2017-CU27-ubuntu-16.04","2017-CU28-ubuntu-16.04","2017-CU29-GDR1-ubuntu-16.04","2017-CU29-ubuntu-16.04","2017-CU3-ubuntu","2017-CU30-ubuntu-18.04","2017-CU31-GDR1-ubuntu-18.04","2017-CU31-GDR2-ubuntu-18.04","2017-CU31-ubuntu-18.04","2017-CU4-ubuntu","2017-CU5-ubuntu","2017-CU6-ubuntu","2017-CU7-ubuntu","2017-CU8-ubuntu","2017-CU9-ubuntu","2017-GA-ubuntu","2017-GDR-ubuntu","2017-GDR3","2017-GDR3-ubuntu","2017-GDR4","2017-GDR4-ubuntu","2017-cu16","2017-cu16-ubuntu","2017-cu17","2017-cu17-ubuntu","2017-cu19","2017-cu19-ubuntu","2017-latest","2017-latest-ubuntu","2019-CU1-ubuntu-16.04","2019-CU10-ubuntu-16.04","2019-CU10-ubuntu-18.04","2019-CU10-ubuntu-20.04","2019-CU11-ubuntu-16.04","2019-CU11-ubuntu-18.04","2019-CU11-ubuntu-20.04","2019-CU12-ubuntu-16.04","2019-CU12-ubuntu-18.04","2019-CU12-ubuntu-20.04","2019-CU13-ubuntu-16.04","2019-CU13-ubuntu-18.04","2019-CU13-ubuntu-20.04","2019-CU14-ubuntu-16.04","2019-CU14-ubuntu-18.04","2019-CU14-ubuntu-20.04","2019-CU15-ubuntu-16.04","2019-CU15-ubuntu-18.04","2019-CU15-ubuntu-20.04","2019-CU16-GDR1-ubuntu-16.04","2019-CU16-GDR1-ubuntu-18.04","2019-CU16-GDR1-ubuntu-20.04","2019-CU16-ubuntu-16.04","2019-CU16-ubuntu-18.04","2019-CU16-ubuntu-20.04","2019-CU17-ubuntu-18.04","2019-CU17-ubuntu-20.04","2019-CU18-GDR1-ubuntu-18.04","2019-CU18-GDR1-ubuntu-20.04","2019-CU18-ubuntu-18.04","2019-CU18-ubuntu-20.04","2019-CU19-ubuntu-18.04","2019-CU19-ubuntu-20.04","2019-CU2-ubuntu-16.04","2019-CU20-ubuntu-18.04","2019-CU20-ubuntu-20.04","2019-CU21-ubuntu-20.04","2019-CU22-GDR1-ubuntu-20.04","2019-CU22-ubuntu-20.04","2019-CU23-ubuntu-20.04","2019-CU24-ubuntu-20.04","2019-CU25-GDR1-ubuntu-20.04","2019-CU25-ubuntu-20.04","2019-CU26-ubuntu-20.04","2019-CU3-ubuntu-16.04","2019-CU3-ubuntu-18.04","2019-CU4-ubuntu-16.04","2019-CU4-ubuntu-18.04","2019-CU5-ubuntu-16.04","2019-CU5-ubuntu-18.04","2019-CU6-ubuntu-16.04","2019-CU6-ubuntu-18.04","2019-CU8-GDR1-ubuntu-16.04","2019-CU8-GDR1-ubuntu-18.04","2019-CU8-OD2-ubuntu-16.04","2019-CU8-OD2-ubuntu-18.04","2019-CU8-ubuntu-16.04","2019-CU8-ubuntu-18.04","2019-CU9-ubuntu-16.04","2019-CU9-ubuntu-18.04","2019-GA-ubuntu-16.04","2019-GDR1-ubuntu-16.04","2019-GDR2-ubuntu-16.04","2019-gdr2-ubuntu-16.04","2019-gdr3-ubuntu-16.04","2019-latest","2022-CTP2.0-ubuntu","2022-CTP2.0-ubuntu-20.04","2022-CU1-ubuntu-20.04","2022-CU10-GDR1-ubuntu-20.04","2022-CU10-GDR1-ubuntu-22.04","2022-CU10-ubuntu-20.04","2022-CU10-ubuntu-22.04","2022-CU11-ubuntu-20.04","2022-CU11-ubuntu-22.04","2022-CU12-GDR1-ubuntu-20.04","2022-CU12-GDR1-ubuntu-22.04","2022-CU12-ubuntu-20.04","2022-CU12-ubuntu-22.04","2022-CU3-ubuntu-20.04","2022-CU4-ubuntu-20.04","2022-CU5-ubuntu-20.04","2022-CU6-ubuntu-20.04","2022-CU7-ubuntu-20.04","2022-CU8-GDR1-ubuntu-20.04","2022-CU8-ubuntu-20.04","2022-CU9-ubuntu-20.04","2022-RC0-ubuntu-20.04","2022-RC1-ubuntu-20.04","2022-RTM-CU1-ubuntu-20.04","2022-RTM-CU2-ubuntu-20.04","2022-RTM-GDR1-ubuntu-20.04","2022-RTM-ubuntu-20.04","2022-latest","2022-preview-ubuntu-22.04","latest","latest-ubuntu"];const D={name:"shared",driver:"bridge"};class Base extends b{options;sequelize=null;constructor(u){super(),this.options=u}async run(u,t){try{if(!this.sequelize)throw new Error("Database connection does not exist");await this.sequelize.query(u,{logging:t})}catch(t){console.error("An error occurred while trying to run the following SQL query:",u,t),n()}return null}async start(u=this.options.clean){console.log(`Starting instance of ${this.name} ⏳`),u&&await this.down(),await this.up(),this.emit(`${this.name}:up`);if(await this.waitUntilReady()){if(console.log(`Database is ready and accepting connections on localhost:${this.options.port} 🗄️`),await this.onDatabaseReady(),this.emit("db:ready"),this.options.logging){const u=await this.getServiceState();u&&await this.showDockerLogs(u.name)}}else console.log(`Failed to start database ${this.name} ⛔`),n(0)}async stop(u=this.options.prune){if(u)await this.down();else{const u=C(this.getDockerComposeConfig());await a({cwd:U(),configAsString:u,log:!0})}this.emit("db:stopped")}async onDatabaseReady(){}getDockerComposeConfig(){return{version:"3.8",services:{db:this.getService()},networks:{shared:D}}}async up(){const u=C(this.getDockerComposeConfig());return s({cwd:U(),configAsString:u,log:!0})}async down(){const u=C(this.getDockerComposeConfig());return i({cwd:U(),configAsString:u,commandOptions:["-v","--remove-orphans","--rmi","local"],log:!0})}async waitUntilReady(){try{const u="mssql"===this.name?"master":this.options.database;return this.sequelize=new c(u,this.options.username,this.options.password,{host:"localhost",port:this.options.port,dialect:this.name.replace("postgresql","postgres"),retry:{max:30,match:[p,d,l,h,m],backoffBase:1e3,backoffExponent:1},logging:!1}),this.sequelize.authenticate().then((()=>!0)).catch((u=>(console.log(u),!1)))}catch(u){return!1}}async getServiceState(){const u=C(this.getDockerComposeConfig());return(await r({configAsString:u,log:!1,commandOptions:["--all"]})).data.services.find((u=>u.name.includes(this.name)))}async showDockerLogs(u){return new Promise(((t,n)=>{o("docker",["logs","-f","-n","5000",u],{cwd:U(),stdio:"inherit"}).on("exit",(u=>0===u?t():n(new Error(`Docker exited with code ${u}`))))}))}}const w={port:1433,database:"dcdx",username:"sa",password:"DataCenterDX!",edition:"Developer",version:"2022"};class MSSQL extends Base{name="mssql";driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";options=w;version="2022";get url(){return`jdbc:sqlserver://db:${this.options.port};databaseName=${this.options.database};trustServerCertificate=true`}constructor(u=w){super({...w,...u})}async onDatabaseReady(){await this.run(`CREATE DATABASE ${this.options.database}`),await this.run(`ALTER DATABASE ${this.options.database} COLLATE SQL_Latin1_General_CP1_CS_AS`),await this.run(`ALTER DATABASE ${this.options.database} SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;`)}getService=()=>({image:`mcr.microsoft.com/mssql/server:${this.version}-latest`,ports:[`${this.options.port||1433}:1433`],environment:{ACCEPT_EULA:"y",MSSQL_SA_PASSWORD:this.options.password||"dcdx",MSSQL_PID:this.options.edition},networks:{shared:{aliases:["db","database"]}}})}(async()=>{const n=u.showHelpAfterError(!0).addOption(new t("-v, --version <version>","The version of Microsoft SQL Server").choices(g).default("latest")).addOption(new t("-e, --edition <edition>","The edition of Microsoft SQL Server").choices(["Developer","Express","Standard","Enterprise","EnterpriseCore"]).default("Developer")).addOption(new t("-p, --port <port>","The port on which the database will be accessible").default("1433")).addOption(new t("-P, --password <password>","The value passed to MSSQL_SA_PASSWORD environment variable. MS SQL Server password policy applies.").default("DataCenterDX!")).addOption(new t("--clean","Remove data files before starting the database").default(!1)).addOption(new t("--prune","Remove data files when stopping the database").default(!1)).parse(process.argv).opts(),o=new MSSQL({version:n.version,edition:n.edition,port:Number(n.port),password:n.password,clean:n.clean,prune:n.prune,logging:!0});e((async()=>{console.log(`Stopping ${o.name}... ⏳`),await o.stop(),console.log(`Stopped ${o.name} 💪`)}),{wait:3e4}),await o.start()})(),process.on("SIGINT",(()=>{console.log("Received term signal, trying to stop gracefully 💪"),n()})),setInterval((()=>{}),1<<30);
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{program as e,Option as o}from"commander";import{gracefulExit as a,asyncExitHook as t}from"exit-hook";import{spawn as s}from"child_process";import{upAll as n}from"docker-compose";import{stop as i,downAll as r,ps as c}from"docker-compose/dist/v2.js";import l from"events";import{dump as d}from"js-yaml";import{cwd as p}from"process";import{Sequelize as m,ConnectionError as h,TimeoutError as u,ConnectionTimedOutError as b,ConnectionRefusedError as g,ConnectionAcquireTimeoutError as w}from"sequelize";var f=["latest","oraclelinux8","oracle","innovation-oraclelinux8","innovation-oracle","innovation","8.3.0-oraclelinux8","8.3.0-oracle","8.3.0","8.3-oraclelinux8","8.3-oracle","8.3","8.0.36-oraclelinux8","8.0.36-oracle","8.0.36-debian","8.0.36-bookworm","8.0.36","8.0-oraclelinux8","8.0-oracle","8.0-debian","8.0-bookworm","8.0","8-oraclelinux8","8-oracle","8","8.0.36-bullseye","8.0-bullseye","8.2.0-oraclelinux8","8.2.0-oracle","8.2.0","8.2-oraclelinux8","8.2-oracle","8.2","8.0.35-oraclelinux8","8.0.35-oracle","8.0.35","8.0.35-debian","8.0.35-bullseye","5.7.44-oraclelinux7","5.7-oraclelinux7","5-oraclelinux7","5.7.44-oracle","5.7.44","5.7-oracle","5.7","5-oracle","5","8.1.0-oracle","8.1.0","8.1-oracle","8.1","8.0.34-oracle","8.0.34","5.7.43-oracle","5.7.43","8.0.34-debian","debian","8-debian","5.7.42-debian","5.7-debian","5-debian","5.7.42-oracle","5.7.42","8.0.33-oracle","8.0.33","8.0.33-debian","8.0.32-debian","5.7.41-debian","8.0.32-oracle","8.0.32","5.7.41-oracle","5.7.41","8.0.31-debian","5.7.40-debian","8.0.31-oracle","8.0.31","5.7.40-oracle","5.7.40","8.0.30-oracle","8.0.30","5.7.39-oracle","5.7.39","8.0.30-debian","5.7.39-debian","8.0.29-oracle","8.0.29","5.7.38-oracle","5.7.38","8.0.29-debian","5.7.38-debian","8.0.28-debian","8.0.28","5.7.37-debian","5.7.37","8.0.28-oracle","5.7.37-oracle","8.0.27","5.7.36","5.6.51","5.6","8.0.26","5.7.35","8.0.25","5.7.34","8.0.24","8.0.23","5.7.33","8.0.22","5.7.32","5.6.50","8.0.21","5.7.31","5.6.49","8.0.20","5.7.30","5.6.48","8.0.19","5.7.29","5.6.47","8.0.18","5.7.28","5.6.46","8.0.17","5.7.27","5.6.45","8.0.16","5.7.26","5.6.44","5.5.62","5.5","5.6.43","5.7.25","8.0.15","8.0.14","5.6.42","5.7.24","8.0.13","5.5.61","5.6.41","5.7.23","8.0.12","5.5.60","5.6.40","5.7.22","8.0.11","5.5.59","5.6.39","5.7.21","8.0.4","8.0.4-rc","8.0.3","5.5.58","5.6.38","5.7.20","5.5.57","5.6.37","5.7.19","8.0.2","5.5.56","5.6.36","5.7.18","8.0.1","5.5.55","5.6.35","5.7.17","8.0.0","5.5.54","5.5.53","5.7.16","5.6.34","5.5.52","5.6.33","5.7.15","5.5.51","5.6.32","5.7.14","5.5.50","5.6.31","5.7.13","5.7.12","5.6.30","5.5.49","5.7.11","5.6.29","5.5.48","5.7.10","5.6.28","5.5.47","5.6.27","5.7.9","5.5.46","5.5.40","5.7.4","5.6.17","5.5.41","5.7.5-m15","5.6.21","5.6.20","5.6.22","5.7.4-m14","5.7.5","5.7.8","5.7.8-rc","5.6.26","5.5.45","5.7.7","5.7.7-rc","5.6.25","5.5.44","5.6.24","5.5.43","5.7.6","5.7.6-m16","5.6.23","5.5.42"];const v={name:"shared",driver:"bridge"};class Base extends l{options;sequelize=null;constructor(e){super(),this.options=e}async run(e,o){try{if(!this.sequelize)throw new Error("Database connection does not exist");await this.sequelize.query(e,{logging:o})}catch(o){console.error("An error occurred while trying to run the following SQL query:",e,o),a()}return null}async start(e=this.options.clean){console.log(`Starting instance of ${this.name} ⏳`),e&&await this.down(),await this.up(),this.emit(`${this.name}:up`);if(await this.waitUntilReady()){if(console.log(`Database is ready and accepting connections on localhost:${this.options.port} 🗄️`),await this.onDatabaseReady(),this.emit("db:ready"),this.options.logging){const e=await this.getServiceState();e&&await this.showDockerLogs(e.name)}}else console.log(`Failed to start database ${this.name} ⛔`),a(0)}async stop(e=this.options.prune){if(e)await this.down();else{const e=d(this.getDockerComposeConfig());await i({cwd:p(),configAsString:e,log:!0})}this.emit("db:stopped")}async onDatabaseReady(){}getDockerComposeConfig(){return{version:"3.8",services:{db:this.getService()},networks:{shared:v}}}async up(){const e=d(this.getDockerComposeConfig());return n({cwd:p(),configAsString:e,log:!0})}async down(){const e=d(this.getDockerComposeConfig());return r({cwd:p(),configAsString:e,commandOptions:["-v","--remove-orphans","--rmi","local"],log:!0})}async waitUntilReady(){try{const e="mssql"===this.name?"master":this.options.database;return this.sequelize=new m(e,this.options.username,this.options.password,{host:"localhost",port:this.options.port,dialect:this.name.replace("postgresql","postgres"),retry:{max:30,match:[h,u,b,g,w],backoffBase:1e3,backoffExponent:1},logging:!1}),this.sequelize.authenticate().then((()=>!0)).catch((e=>(console.log(e),!1)))}catch(e){return!1}}async getServiceState(){const e=d(this.getDockerComposeConfig());return(await c({configAsString:e,log:!1,commandOptions:["--all"]})).data.services.find((e=>e.name.includes(this.name)))}async showDockerLogs(e){return new Promise(((o,a)=>{s("docker",["logs","-f","-n","5000",e],{cwd:p(),stdio:"inherit"}).on("exit",(e=>0===e?o():a(new Error(`Docker exited with code ${e}`))))}))}}const y={port:3306,database:"dcdx",username:"dcdx",password:"dcdx",version:"8.0"};class MySQL extends Base{name="mysql";driver="com.mysql.jdbc.Driver";options=y;version="8.0";get url(){return`jdbc:mysql://db:${this.options.port}/${this.options.database}?sessionVariables=transaction_isolation='READ-COMMITTED'`}constructor(e=y){super({...y,...e})}async onDatabaseReady(){await this.run(`ALTER DATABASE ${this.options.database} CHARACTER SET 'utf8mb4' COLLATE utf8mb4_bin`)}getService=()=>({image:`mysql:${this.version}`,ports:[`${this.options.port||3306}:3306`],environment:{MYSQL_ROOT_PASSWORD:this.options.password||"dcdx",MYSQL_USER:this.options.username||"dcdx",MYSQL_PASSWORD:this.options.password||"dcdx",MYSQL_DATABASE:this.options.database||"dcdx"},command:["--log_bin_trust_function_creators=1"],networks:{shared:{aliases:["db","database"]}}})}(async()=>{const a=e.showHelpAfterError(!0).addOption(new o("-v, --version <version>","The version of MySQL").choices(f).default("latest")).addOption(new o("-d, --database <database>","The value passed to MYSQL_DATABASE environment variable").default("dcdx")).addOption(new o("-p, --port <port>","The port on which the database will be accessible").default("3306")).addOption(new o("-U, --username <username>","The value passed to MYSQL_USER environment variable").default("dcdx")).addOption(new o("-P, --password <password>","The value passed to MYSQL_PASSWORD environment variable").default("dcdx")).addOption(new o("--clean","Remove data files before starting the database").default(!1)).addOption(new o("--prune","Remove data files when stopping the database").default(!1)).parse(process.argv).opts(),s=new MySQL({version:a.version,database:a.database,port:Number(a.port),username:a.username,password:a.password,clean:a.clean,prune:a.prune,logging:!0});t((async()=>{console.log(`Stopping ${s.name}... ⏳`),await s.stop(),console.log(`Stopped ${s.name} 💪`)}),{wait:3e4}),await s.start()})(),process.on("SIGINT",(()=>{console.log("Received term signal, trying to stop gracefully 💪"),a()})),setInterval((()=>{}),1<<30);
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{program as e,Option as a}from"commander";import{gracefulExit as l,asyncExitHook as n}from"exit-hook";import{spawn as i}from"child_process";import{upAll as p}from"docker-compose";import{stop as t,downAll as s,ps as o}from"docker-compose/dist/v2.js";import r from"events";import{dump as b}from"js-yaml";import{cwd as c}from"process";import{Sequelize as u,ConnectionError as d,TimeoutError as y,ConnectionTimedOutError as m,ConnectionRefusedError as h,ConnectionAcquireTimeoutError as w}from"sequelize";var g=["latest","bullseye","bookworm","alpine3.19","alpine3.18","alpine","16.2-bullseye","16.2-bookworm","16.2-alpine3.19","16.2-alpine3.18","16.2-alpine","16.2","16-bullseye","16-bookworm","16-alpine3.19","16-alpine3.18","16-alpine","16","15.6-bullseye","15.6-bookworm","15.6-alpine3.19","15.6-alpine3.18","15.6-alpine","15.6","15-bullseye","15-bookworm","15-alpine3.19","15-alpine3.18","15-alpine","15","14.11-bullseye","14.11-bookworm","14.11-alpine3.19","14.11-alpine3.18","14.11-alpine","14.11","14-bullseye","14-bookworm","14-alpine3.19","14-alpine3.18","14-alpine","14","13.14-bullseye","13.14-bookworm","13.14-alpine3.19","13.14-alpine3.18","13.14-alpine","13.14","13-bullseye","13-bookworm","13-alpine3.19","13-alpine3.18","13-alpine","13","12.18-bullseye","12.18-bookworm","12.18-alpine3.19","12.18-alpine3.18","12.18-alpine","12.18","12-bullseye","12-bookworm","12-alpine3.19","12-alpine3.18","12-alpine","12","16.1-bullseye","15.5-bullseye","15.5-bookworm","15.5","14.10-bullseye","14.10-bookworm","14.10","13.13-bullseye","13.13-bookworm","13.13","12.17-bullseye","12.17-bookworm","12.17","16.1-bookworm","16.1","16.1-alpine3.19","16.1-alpine3.18","16.1-alpine","15.5-alpine3.19","15.5-alpine3.18","15.5-alpine","14.10-alpine3.19","14.10-alpine3.18","14.10-alpine","13.13-alpine3.19","13.13-alpine3.18","13.13-alpine","12.17-alpine3.19","12.17-alpine3.18","12.17-alpine","11.22-bullseye","11.22-bookworm","11-bullseye","11-bookworm","11.22-alpine3.19","11.22-alpine","11-alpine3.19","11-alpine","12.17-alpine3.17","12-alpine3.17","11.22-alpine3.18","11.22-alpine3.17","11-alpine3.18","11-alpine3.17","alpine3.17","16.1-alpine3.17","16-alpine3.17","15.5-alpine3.17","15-alpine3.17","13.13-alpine3.17","13-alpine3.17","14.10-alpine3.17","14-alpine3.17","12.16-bullseye","11.21-bullseye","11.21-bookworm","13.12-bullseye","13.12-bookworm","13.12","12.16-bookworm","12.16","14.9-bullseye","14.9-bookworm","14.9","16.0-bullseye","15.4-bullseye","15.4-bookworm","15.4","16.0-bookworm","16.0","16.0-alpine3.18","16.0-alpine3.17","16.0-alpine","15.4-alpine3.18","15.4-alpine3.17","15.4-alpine","14.9-alpine3.18","14.9-alpine3.17","14.9-alpine","13.12-alpine3.18","13.12-alpine3.17","13.12-alpine","12.16-alpine3.18","12.16-alpine3.17","12.16-alpine","11.21-alpine3.18","11.21-alpine3.17","11.21-alpine","16rc1-bullseye","16rc1-bookworm","16rc1","16rc1-alpine3.18","16rc1-alpine3.17","16rc1-alpine","16beta3-bullseye","16beta3-bookworm","16beta3","16beta3-alpine3.18","16beta3-alpine3.17","16beta3-alpine","16beta2-alpine3.18","16beta2-alpine3.17","16beta2-alpine","15.3-alpine3.18","15.3-alpine3.17","15.3-alpine","14.8-alpine3.18","14.8-alpine3.17","14.8-alpine","13.11-alpine3.18","13.11-alpine3.17","13.11-alpine","12.15-alpine3.18","12.15-alpine3.17","12.15-alpine","11.20-alpine3.18","11.20-alpine3.17","11.20-alpine","16beta2-bullseye","16beta2-bookworm","16beta2","15.3-bullseye","15.3-bookworm","15.3","14.8-bullseye","14.8-bookworm","14.8","13.11-bullseye","13.11-bookworm","13.11","12.15-bullseye","12.15-bookworm","12.15","11.20-bullseye","11.20-bookworm","16beta1-bookworm","16beta1-alpine3.18","16beta1-alpine3.17","16beta1-alpine","16beta1","16beta1-bullseye","15.2-bullseye","15.2-alpine3.17","15.2-alpine","15.2","14.7-bullseye","14.7-alpine3.17","14.7-alpine","14.7","13.10-bullseye","13.10-alpine3.17","13.10-alpine","13.10","12.14-bullseye","12.14-alpine3.17","12.14-alpine","12.14","11.19-bullseye","11.19-alpine3.17","11.19-alpine","15.1-bullseye","15.1","14.6-bullseye","14.6","13.9-bullseye","13.9","12.13-bullseye","12.13","11.18-bullseye","15.1-alpine3.17","15.1-alpine","14.6-alpine3.17","14.6-alpine","13.9-alpine3.17","13.9-alpine","12.13-alpine3.17","12.13-alpine","11.18-alpine3.17","11.18-alpine","alpine3.16","15.1-alpine3.16","15-alpine3.16","14.6-alpine3.16","14-alpine3.16","13.9-alpine3.16","13-alpine3.16","12.13-alpine3.16","12-alpine3.16","11.18-alpine3.16","11-alpine3.16","10.23-alpine3.16","10.23-alpine","10-alpine3.16","10-alpine","10.23-bullseye","10-bullseye","15.0-bullseye","14.5-bullseye","14.5","13.8-bullseye","13.8","12.12-bullseye","12.12","11.17-bullseye","10.22-bullseye","15.0","15.0-alpine3.16","15.0-alpine","14.5-alpine3.16","14.5-alpine","13.8-alpine3.16","13.8-alpine","12.12-alpine3.16","12.12-alpine","11.17-alpine3.16","11.17-alpine","10.22-alpine3.16","10.22-alpine","15rc2-alpine3.16","15rc2-alpine","15rc2-bullseye","15rc2","15rc1-alpine3.16","15rc1-alpine","15rc1-bullseye","15rc1","15beta4-bullseye","15beta4","15beta4-alpine3.16","15beta4-alpine","15beta3-bullseye","15beta3","15beta3-alpine3.16","15beta3-alpine","15beta2-alpine3.16","15beta2-alpine","14.4-alpine3.16","14.4-alpine","13.7-alpine3.16","13.7-alpine","12.11-alpine3.16","12.11-alpine","11.16-alpine3.16","11.16-alpine","10.21-alpine3.16","10.21-alpine","12.11-bullseye","12.11","15beta2-bullseye","15beta2","14.4-bullseye","14.4","13.7-bullseye","13.7","11.16-bullseye","10.21-bullseye","15beta1-bullseye","15beta1","11.16-stretch","11.16","11-stretch","11","10.21-stretch","10.21","10-stretch","10","15beta1-alpine3.16","15beta1-alpine","14.3-alpine3.16","14.3-alpine","14.3-bullseye","14.3","15beta1-alpine3.15","alpine3.15","14.3-alpine3.15","14-alpine3.15","13.7-alpine3.15","13-alpine3.15","12.11-alpine3.15","12-alpine3.15","11.16-alpine3.15","11-alpine3.15","10.21-alpine3.15","10-alpine3.15","14.2-bullseye","14.2","13.6-bullseye","13.6","12.10-bullseye","12.10","11.15-bullseye","10.20-bullseye","11.15-stretch","11.15","10.20-stretch","10.20","14.2-alpine3.15","14.2-alpine","13.6-alpine3.15","13.6-alpine","12.10-alpine3.15","12.10-alpine","11.15-alpine3.15","11.15-alpine","10.20-alpine3.15","10.20-alpine","9.6.24-bullseye","9.6-bullseye","9-bullseye","9.6.24-stretch","9.6.24","9.6-stretch","9.6","9-stretch","9","14.1-bullseye","14.1","13.5-bullseye","13.5","12.9-bullseye","12.9","11.14-stretch","11.14-bullseye","11.14","10.19-stretch","10.19-bullseye","10.19","9.6.24-alpine3.15","9.6.24-alpine","9.6-alpine3.15","9.6-alpine","9-alpine3.15","9-alpine","14.1-alpine3.15","14.1-alpine","13.5-alpine3.15","13.5-alpine","12.9-alpine3.15","12.9-alpine","11.14-alpine3.15","11.14-alpine","10.19-alpine3.15","10.19-alpine","alpine3.14","9.6.24-alpine3.14","9.6-alpine3.14","9-alpine3.14","14.1-alpine3.14","14-alpine3.14","13.5-alpine3.14","13-alpine3.14","12.9-alpine3.14","12-alpine3.14","11.14-alpine3.14","11-alpine3.14","10.19-alpine3.14","10-alpine3.14","9.6.23-stretch","9.6.23-bullseye","9.6.23-alpine3.14","9.6.23-alpine","9.6.23","14.0-bullseye","14.0-alpine3.14","14.0-alpine","14.0","13.4-bullseye","13.4-alpine3.14","13.4-alpine","13.4","12.8-bullseye","12.8-alpine3.14","12.8-alpine","12.8","11.13-stretch","11.13-bullseye","11.13-alpine3.14","11.13-alpine","11.13","10.18-stretch","10.18-bullseye","10.18-alpine3.14","10.18-alpine","10.18","14rc1-bullseye","14rc1","14rc1-alpine3.14","14rc1-alpine","buster","9.6.23-buster","9.6-buster","9-buster","14beta3-buster","14beta3","13.4-buster","13-buster","12.8-buster","12-buster","11.13-buster","11-buster","10.18-buster","10-buster","14beta3-alpine3.14","14beta3-alpine","9.6.22-alpine3.14","9.6.22-alpine","14beta2-alpine3.14","14beta2-alpine","13.3-alpine3.14","13.3-alpine","12.7-alpine3.14","12.7-alpine","11.12-alpine3.14","11.12-alpine","10.17-alpine3.14","10.17-alpine","9.6.22-stretch","9.6.22-buster","9.6.22","14beta2-buster","14beta2","13.3-buster","13.3","12.7-buster","12.7","11.12-stretch","11.12-buster","11.12","10.17-stretch","10.17-buster","10.17","alpine3.13","9-alpine3.13","13.3-alpine3.13","13-alpine3.13","12.7-alpine3.13","12-alpine3.13","11.12-alpine3.13","11-alpine3.13","10.17-alpine3.13","10-alpine3.13","9.6.22-alpine3.13","9.6-alpine3.13","9.6.21","9.5.25","9.5","13.2","12.6","11.11","10.16","9.6.21-alpine","9.5.25-alpine","9.5-alpine","13.2-alpine","12.6-alpine","11.11-alpine","10.16-alpine","9.6.20","9.5.24","13.1","12.5","11.10","10.15","9.6.20-alpine","9.5.24-alpine","13.1-alpine","12.5-alpine","11.10-alpine","10.15-alpine","9.6.19-alpine","9.5.23-alpine","13.0-alpine","12.4-alpine","11.9-alpine","10.14-alpine","9.6.19","9.5.23","13.0","12.4","11.9","10.14","13-rc1-alpine","13-rc1","13-beta3","13-beta3-alpine","9.6.18","9.5.22","13-beta2","12.3","11.8","10.13","9.6.18-alpine","9.5.22-alpine","13-beta2-alpine","12.3-alpine","11.8-alpine","10.13-alpine","13-beta1-alpine","13-beta1","9.6.17","9.5.21","11.7","10.12","9.6.17-alpine","9.5.21-alpine","12.2-alpine","11.7-alpine","10.12-alpine","12.2","9.4.26-alpine","9.4.26","9.4-alpine","9.4","9.6.16","9.5.20","9.4.25","12.1","11.6","10.11","9.6.16-alpine","9.5.20-alpine","9.4.25-alpine","12.1-alpine","11.6-alpine","10.11-alpine","9.6.15-alpine","9.5.19-alpine","9.4.24-alpine","12.0-alpine","11.5-alpine","10.10-alpine","9.6.15","9.5.19","9.4.24","12.0","11.5","10.10","12-rc1-alpine","12-rc1","12-beta4-alpine","12-beta4","12-beta3","12-beta3-alpine","9.6.14-alpine","9.5.18-alpine","9.4.23-alpine","12-beta2-alpine","11.4-alpine","10.9-alpine","9.6.14","9.5.18","9.4.23","11.4","10.9","12-beta2","9.6.13-alpine","9.5.17-alpine","9.4.22-alpine","12-beta1-alpine","11.3-alpine","10.8-alpine","9.6.13","9.5.17","9.4.22","12-beta1","11.3","10.8","11.2","9.4.21","9.5.16","9.6.12","10.7","9.4.21-alpine","9.5.16-alpine","9.6.12-alpine","10.7-alpine","11.2-alpine","9.4.20","9.5.15","9.6.11","10.6","11.1","9.4.20-alpine","9.5.15-alpine","9.6.11-alpine","10.6-alpine","11.1-alpine","9.3","9.3.25","9.3-alpine","9.3.25-alpine","10.5-alpine","10.5","11.0","11.0-alpine","9.3.24","9.4.19","9.5.14","9.6.10","11-rc1","11-rc1-alpine","11-beta4-alpine","9.4.19-alpine","11-beta4","9.3.24-alpine","9.5.14-alpine","9.6.10-alpine","11-beta3-alpine","11-beta3","9.3.23","9.5.13","9.5.13-alpine","9.4.18","9.6.9","10.4-alpine","10.4","11-beta2-alpine","11-beta2","9.4.18-alpine","9.3.23-alpine","9.6.9-alpine","11-beta1","11-beta1-alpine","9.6.8","10.3","9.3.22-alpine","9.3.22","9.4.17-alpine","9.4.17","9.5.12-alpine","9.5.12","9.6.8-alpine","10.3-alpine","9.3.21","9.4.16","9.5.11","9.6.7","10.2-alpine","10.2","9.5.11-alpine","9.5.10","9.3.21-alpine","9.4.16-alpine","9.6.7-alpine","9.3.20-alpine","9.4.15-alpine","9.5.10-alpine","9.6.6-alpine","10.1-alpine","9.3.20","9.4.15","9.6.6","10.1","9.3.19-alpine","9.3.19","9.4.14-alpine","9.4.14","9.5.9-alpine","9.5.9","9.6.5-alpine","9.6.5","10.0-alpine","10.0","9.2","9.2.23","10-rc1","9.2-alpine","9.2.23-alpine","10-rc1-alpine","10-beta4","10-beta4-alpine","9.2.22-alpine","9.2.22","9.3.18-alpine","9.3.18","9.4.13-alpine","9.4.13","9.5.8-alpine","9.5.8","9.6.4-alpine","9.6.4","10-beta3-alpine","10-beta3","9.2.21-alpine","9.2.21","9.3.17-alpine","9.3.17","9.4.12-alpine","9.4.12","9.5.7-alpine","9.5.7","9.6.3-alpine","9.6.3","10-beta2-alpine","10-beta2","10-beta1-alpine","10-beta1","9.2.20-alpine","9.2.20","9.3.16-alpine","9.3.16","9.4.11-alpine","9.4.11","9.5.6-alpine","9.5.6","9.6.2-alpine","9.6.2","9.2.19-alpine","9.2.19","9.3.15-alpine","9.3.15","9.4.10-alpine","9.4.10","9.5.5-alpine","9.5.5","9.6.1-alpine","9.6.1","9.1.24","9.1","9.5.4","9.4.9","9.3.14","9.2.18","9.1.23","9.6.0","9.6-rc1","9.6-beta4","9.4.8","9.1.22","9.6-beta3","9.5.3","9.3.13","9.2.17","9.6-beta2","9.6-beta1","9.5.2","9.4.7","9.3.12","9.2.16","9.1.21","9.5.1","9.4.6","9.3.11","9.2.15","9.1.20","9.5.0","9.4.5","9.3.10","9.2.14","9.1.19","9.0","9.0.22","9.5-rc1","9.5-beta2","9.5-beta1","9.4-rc1","9.3.5","9.4-beta2","9.2.9","9.4.0","9.1.14","9.4-beta3","9.0.18","9.5-alpha2","9.4.4","9.3.9","9.2.13","9.1.18","9.5-alpha1","9.4.3","9.3.8","9.2.12","9.1.17","9.0.21","9.4.2","9.3.7","9.2.11","9.1.16","9.0.20","8","8.4","8.4.22","9.4.1","9.3.6","9.2.10","9.1.15","9.0.19"];const k={name:"shared",driver:"bridge"};class Base extends r{options;sequelize=null;constructor(e){super(),this.options=e}async run(e,a){try{if(!this.sequelize)throw new Error("Database connection does not exist");await this.sequelize.query(e,{logging:a})}catch(a){console.error("An error occurred while trying to run the following SQL query:",e,a),l()}return null}async start(e=this.options.clean){console.log(`Starting instance of ${this.name} ⏳`),e&&await this.down(),await this.up(),this.emit(`${this.name}:up`);if(await this.waitUntilReady()){if(console.log(`Database is ready and accepting connections on localhost:${this.options.port} 🗄️`),await this.onDatabaseReady(),this.emit("db:ready"),this.options.logging){const e=await this.getServiceState();e&&await this.showDockerLogs(e.name)}}else console.log(`Failed to start database ${this.name} ⛔`),l(0)}async stop(e=this.options.prune){if(e)await this.down();else{const e=b(this.getDockerComposeConfig());await t({cwd:c(),configAsString:e,log:!0})}this.emit("db:stopped")}async onDatabaseReady(){}getDockerComposeConfig(){return{version:"3.8",services:{db:this.getService()},networks:{shared:k}}}async up(){const e=b(this.getDockerComposeConfig());return p({cwd:c(),configAsString:e,log:!0})}async down(){const e=b(this.getDockerComposeConfig());return s({cwd:c(),configAsString:e,commandOptions:["-v","--remove-orphans","--rmi","local"],log:!0})}async waitUntilReady(){try{const e="mssql"===this.name?"master":this.options.database;return this.sequelize=new u(e,this.options.username,this.options.password,{host:"localhost",port:this.options.port,dialect:this.name.replace("postgresql","postgres"),retry:{max:30,match:[d,y,m,h,w],backoffBase:1e3,backoffExponent:1},logging:!1}),this.sequelize.authenticate().then((()=>!0)).catch((e=>(console.log(e),!1)))}catch(e){return!1}}async getServiceState(){const e=b(this.getDockerComposeConfig());return(await o({configAsString:e,log:!1,commandOptions:["--all"]})).data.services.find((e=>e.name.includes(this.name)))}async showDockerLogs(e){return new Promise(((a,l)=>{i("docker",["logs","-f","-n","5000",e],{cwd:c(),stdio:"inherit"}).on("exit",(e=>0===e?a():l(new Error(`Docker exited with code ${e}`))))}))}}const f={version:"15",database:"dcdx",port:5432,username:"dcdx",password:"dcdx"};class Postgres extends Base{name="postgresql";driver="org.postgresql.Driver";options=f;version="15";get url(){return`jdbc:postgresql://db:${this.options.port}/${this.options.database}`}constructor(e=f){super({...f,...e})}getService=()=>({image:`postgres:${this.version}`,ports:[`${this.options.port||5432}:5432`],environment:{POSTGRES_USER:this.options.username||"dcdx",POSTGRES_PASSWORD:this.options.password||"dcdx",POSTGRES_DB:this.options.database||"dcdx",POSTGRES_HOST_AUTH_METHOD:"md5",POSTGRES_INITDB_ARGS:"--encoding=UTF-8 --lc-collate=C --lc-ctype=C"},networks:{shared:{aliases:["db","database"]}}})}(async()=>{const l=e.showHelpAfterError(!0).addOption(new a("-v, --version <version>","The version of Postgres").choices(g).default("latest")).addOption(new a("-d, --database <database>","The value passed to POSTGRES_DB environment variable").default("dcdx")).addOption(new a("-p, --port <port>","The port on which the database will be accessible").default("5432")).addOption(new a("-U, --username <username>","The value passed to POSTGRES_USER environment variable").default("dcdx")).addOption(new a("-P, --password <password>","The value passed to POSTGRES_PASSWORD environment variable").default("dcdx")).addOption(new a("--clean","Remove data files before starting the database").default(!1)).addOption(new a("--prune","Remove data files when stopping the database").default(!1)).parse(process.argv).opts(),i=new Postgres({version:l.version,database:l.database,port:Number(l.port),username:l.username,password:l.password,clean:l.clean,prune:l.prune,logging:!0});n((async()=>{console.log(`Stopping ${i.name}... ⏳`),await i.stop(),console.log(`Stopped ${i.name} 💪`)}),{wait:3e4}),await i.start()})(),process.on("SIGINT",(()=>{console.log("Received term signal, trying to stop gracefully 💪"),l()})),setInterval((()=>{}),1<<30);