@adinsure-ops/ops-cli 5.1.2 → 5.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.
@@ -20,7 +20,7 @@ export default class Sql extends CommandBase<typeof Sql> {
20
20
  'column-type': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
21
21
  };
22
22
  private readonly _moduleTypes;
23
- private readonly _dbmsType;
23
+ private _dbmsTypes;
24
24
  /**
25
25
  * Get unique Script ID zip by specified version
26
26
  * @param {string} version The version of Identity Server
@@ -37,6 +37,7 @@ export default class Sql extends CommandBase<typeof Sql> {
37
37
  handleLayer(scriptDbmsFolder: string, scriptLayer: string, scriptType: string, dbmsFormat: string): Promise<string>;
38
38
  sqlExtendScriptGeneration(tableSchema: string | undefined, tableName: string | undefined, columnName: string | undefined, columnType: string | undefined): Promise<string>;
39
39
  oradcExtendScriptGeneration(tableSchema: string | undefined, tableName: string | undefined, columnName: string | undefined, columnType: string | undefined): Promise<string>;
40
+ postgresExtendScriptGeneration(tableSchema: string | undefined, tableName: string | undefined, columnName: string | undefined, columnType: string | undefined): Promise<string>;
40
41
  checkExtendParameters(): Promise<string[]>;
41
42
  run(): Promise<void>;
42
43
  }
@@ -21,7 +21,23 @@ class Sql extends CommandBase {
21
21
  reins: 'Reinsurance',
22
22
  shared: 'Shared',
23
23
  };
24
- this._dbmsType = ['sql', 'oradc'];
24
+ this._dbmsTypes = [
25
+ {
26
+ name: 'sql',
27
+ scriptLocation: undefined,
28
+ extendGenerator: this.sqlExtendScriptGeneration
29
+ },
30
+ {
31
+ name: 'oradc',
32
+ scriptLocation: undefined,
33
+ extendGenerator: this.oradcExtendScriptGeneration
34
+ },
35
+ {
36
+ name: 'postgres',
37
+ scriptLocation: undefined,
38
+ extendGenerator: this.postgresExtendScriptGeneration
39
+ }
40
+ ];
25
41
  }
26
42
  /**
27
43
  * Get unique Script ID zip by specified version
@@ -122,12 +138,19 @@ BEGIN
122
138
  end;`;
123
139
  });
124
140
  }
141
+ postgresExtendScriptGeneration(tableSchema, tableName, columnName, columnType) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ return `ALTER TABLE IF EXISTS ${tableSchema}.${tableName}
144
+ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
145
+ `;
146
+ });
147
+ }
125
148
  checkExtendParameters() {
126
149
  return __awaiter(this, void 0, void 0, function* () {
127
150
  const { flags } = yield this.parse(Sql);
128
151
  const arrayOfParameters = [];
129
152
  if (flags['table-schema'] === undefined) {
130
- arrayOfParameters.push('table-scehma');
153
+ arrayOfParameters.push('table-schema');
131
154
  }
132
155
  if (flags['table-name'] === undefined) {
133
156
  arrayOfParameters.push('table-name');
@@ -218,13 +241,12 @@ end;`;
218
241
  if (!(yield fs.pathExists(scriptsRootFolder))) {
219
242
  this.error(`Could not resolve database scripts folder: ${scriptsRootFolder}`);
220
243
  }
221
- const scriptFolderLocations = [];
222
- for (const dbmsFormat of this._dbmsType) {
223
- const scriptDbmsFolder = path.resolve(scriptsRootFolder, dbmsFormat);
244
+ for (const dbmsFormat of this._dbmsTypes) {
245
+ const scriptDbmsFolder = path.resolve(scriptsRootFolder, dbmsFormat.name);
224
246
  if (yield fs.pathExists(scriptDbmsFolder)) {
225
247
  let scriptFolder = path.resolve(scriptDbmsFolder, scriptType);
226
248
  if (scriptLayer !== undefined) {
227
- scriptFolder = yield this.handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat);
249
+ scriptFolder = yield this.handleLayer(scriptDbmsFolder, scriptLayer, scriptType, dbmsFormat.name);
228
250
  }
229
251
  if (scriptModule !== undefined) {
230
252
  scriptFolder = path.resolve(scriptFolder, this._moduleTypes[scriptModule]);
@@ -233,7 +255,7 @@ end;`;
233
255
  this.warn(`Could not resolve existing database scripts folder. Creating folder: ${scriptFolder}`);
234
256
  yield fs.mkdir(scriptFolder);
235
257
  }
236
- scriptFolderLocations.push(scriptFolder);
258
+ dbmsFormat.scriptLocation = scriptFolder;
237
259
  }
238
260
  }
239
261
  // Validation of parameters succeed. Requesting new SQL script ID and creating file.
@@ -247,27 +269,12 @@ end;`;
247
269
  scriptId = (yield this.getScriptId(version.version)).data;
248
270
  this.log(`Got: '${chalk.green(scriptId)}'`);
249
271
  }
250
- // Check if the operation is Extend
251
- if (scriptType === 'Extend') {
252
- // The first file will always be in \sql\ folder for mssql
253
- // and the second one will always be in \oradc\ for oracle db
254
- let sqlOrOradc = 0;
255
- for (const scriptFolder of scriptFolderLocations) {
256
- const scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
257
- // The values in flags such as table-schema, which are passed into the sql generation function can never be undefined as they
258
- // are checked prior to executing this code, so the functions are defined in a way where they can intake an undefined parameter
259
- // only due to typescript.
260
- yield (sqlOrOradc ? fs.writeFile(scriptsFilePath, yield this.oradcExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type'])) : fs.writeFile(scriptsFilePath, yield this.sqlExtendScriptGeneration(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type'])));
261
- this.log(`${chalk.yellow(scriptsFilePath)}`);
262
- sqlOrOradc++;
263
- }
264
- }
265
- else {
266
- for (const scriptFolder of scriptFolderLocations) {
267
- const scriptsFilePath = path.resolve(scriptFolder, `${scriptId}.sql`);
268
- yield fs.writeFile(scriptsFilePath, '');
269
- this.log(`${chalk.yellow(scriptsFilePath)}`);
270
- }
272
+ const usedDbmsTypes = this._dbmsTypes.filter(it => it.scriptLocation !== undefined);
273
+ for (const usedDbmsType of usedDbmsTypes) {
274
+ const scriptsFilePath = path.resolve(usedDbmsType.scriptLocation, `${scriptId}.sql`);
275
+ const content = scriptType === 'Extend' ? yield usedDbmsType.extendGenerator(flags['table-schema'], flags['table-name'], flags['column-name'], flags['column-type']) : '';
276
+ yield fs.writeFile(scriptsFilePath, content);
277
+ this.log(`${chalk.yellow(scriptsFilePath)}`);
271
278
  }
272
279
  });
273
280
  }
@@ -23,7 +23,7 @@ class Version extends CommandBase {
23
23
  const currentPrereleaseDate = moment().format('YYYYMM');
24
24
  const bumpedPackageName = [];
25
25
  // Find all package.json files that are not in node modules
26
- const searchPattern = ['**/package.json', '!**/node_modules'];
26
+ const searchPattern = ['**/package.json', '.**/package.json', '!**/node_modules'];
27
27
  if (excludeDirs) {
28
28
  for (const exclude of excludeDirs) {
29
29
  searchPattern.push(`!${exclude}`);
@@ -94,7 +94,7 @@ class Version extends CommandBase {
94
94
  updateDependencies(version, updatedPackages) {
95
95
  return __awaiter(this, void 0, void 0, function* () {
96
96
  // Find all package.json files that are not in node modules
97
- const paths = yield globby(['**/package.json', '!**/node_modules']);
97
+ const paths = yield globby(['**/package.json', '.**/package.json', '!**/node_modules']);
98
98
  for (const path of paths) {
99
99
  for (const packageName of updatedPackages) {
100
100
  const re = new RegExp('"' + packageName + '": "\\d+\\.\\d+\\..*"', 'g');
package/lib/lib/npm.js CHANGED
@@ -37,10 +37,10 @@ export default class NpmContext {
37
37
  return __awaiter(this, arguments, void 0, function* (context, packages = ['**/*'], excludes = ['']) {
38
38
  try {
39
39
  const workspaces = yield this.getWorkspaces();
40
- let searchPattern = ['package.json', '**/package.json', '!**/node_modules'];
40
+ let searchPattern = ['package.json', '**/package.json', '.**/package.json', '!**/node_modules'];
41
41
  const pkgs = [];
42
42
  if (workspaces.length > 0) {
43
- searchPattern = [...workspaces, 'package.json', '!**/node_modules'];
43
+ searchPattern = [...workspaces, 'package.json', '.*/package.json', '!**/node_modules'];
44
44
  }
45
45
  const pkgPaths = yield globby(searchPattern);
46
46
  for (const pkgPath of pkgPaths) {
@@ -1589,5 +1589,5 @@
1589
1589
  ]
1590
1590
  }
1591
1591
  },
1592
- "version": "5.1.2"
1592
+ "version": "5.2.0"
1593
1593
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adinsure-ops/ops-cli",
3
3
  "description": "Operations CLI for working with AdInsure",
4
- "version": "5.1.2",
4
+ "version": "5.2.0",
5
5
  "author": "Adacta Digital Service Department",
6
6
  "bin": {
7
7
  "ops": "./bin/run.js"
@@ -123,4 +123,4 @@
123
123
  "eslint": "eslint --quiet --config .eslint.config.js --fix"
124
124
  },
125
125
  "types": "lib/index.d.ts"
126
- }
126
+ }
package/CHANGELOGS.md DELETED
@@ -1,198 +0,0 @@
1
- # Changelogs
2
-
3
- ## 5.1.2: 2024-07-04
4
-
5
- - LJADIRD-43932: updated all core (oclif) and non-core dependencies
6
- - LJADIRDSUP-15178: added acquiring token by refreshToken functionality into security context
7
- - LJADIRD-47453: updated create-nightly-tag regex to match correct versions and create new tag
8
-
9
- ## 5.1.1: 2024-05-13
10
-
11
- - LJADIRD-46524: added more verbose output to the security context when aquiring token
12
-
13
- ## 5.1.0: 2024-03-29
14
-
15
- - LJADIRDSUP-13830: added verbose error output when downloading studio and installing the plugin into the VSCode
16
- - LJADIRD-45744: removed Node.js v16 support, only supporting Node.js >=18
17
-
18
- ## 5.0.11: 2024-03-26
19
-
20
- - LJADIRD-45711: updated regex for matching tags in the gitlab:next-nightly-tag command
21
-
22
- ## 5.0.10: 2024-03-20
23
-
24
- - LJADIRDSUP-13469: added gurads for checking if the npmrc file being read is a directory
25
-
26
- ## 5.0.9: 2024-01-03
27
-
28
- - ops-cli sql command is now case insensitive
29
- - LJADIRDSUP-12244: axios already returns json and doesn't need to be parsed again
30
-
31
- ## 5.0.8: 2023-12-22
32
-
33
- - gitlab:get-nightly-tag command request is fixed since the parameters in the HTTP header were misconfigured
34
-
35
- ## 5.0.7: 2023-12-18
36
-
37
- - Sql command can now accept aruguments in lowercase as well as with a capital first letter
38
- - Bugfix: sql path will now stop capitalizing the extend, migration, data and schema directory
39
-
40
- ## 5.0.6: 2023-12-14
41
-
42
- - Node 16 support added
43
-
44
- ## 5.0.5: 2023-11-20
45
-
46
- - Fixed the ops-cli releasing cycle as a few minor releases were not uploaded to npm.js
47
-
48
- ## 5.0.4: 2023-09-27
49
-
50
- - Fixed version command's post request, where the headers were actually stored in the body
51
-
52
- ## 5.0.3: 2023-09-25
53
-
54
- - Updated node engine support to also include 20.x and deprecated the use of 14.x
55
-
56
- ## 5.0.2: 2023-09-14
57
-
58
- - Fixed download commands and their output flag
59
- - Fixed translate command to have correct url in the get request
60
-
61
- ## 5.0.1: 2023-09-12
62
-
63
- - Updated ops-cli to the stable version 5.x
64
- - Prepare-content command is back! But with a differenct syntax than before, so check the README
65
- - Faster performance and updated dependencies
66
-
67
- ## 5.0.0: 2023-09-08
68
-
69
- - Added --description flag to the log command. It accepts the description of the changelog which will be used
70
- - Added --force flag to the log command. It creates folder structure if missing
71
- - Added --keep flag to the download:studio command
72
- - Bugfixes
73
- - Security patching: the project was migrated to a new oclif framework from the old one
74
- - Performace tuning
75
- - [DEPRECATED] Deprecation and removal of the prepare-content command
76
- - [REMOVED] `--servicePrincipal` login is no longer available or required. 'AZURE_CLIENT_ID' and 'AZURE_CLIENT_SECRET' environment variables are required with every command in order to use service principal.
77
-
78
- ## 4.8.3: 2023-08-22
79
-
80
- - Bugfixes; sql command was fixed so that even when Extend was not used it required its parameters
81
- - Security patches in library dependencies
82
-
83
- ## 4.8.2: 2023-07-28
84
-
85
- - Sql command can now generate a template for mssql and oracle, for extending an sql table with a column
86
-
87
- ## 4.8.1: 2023-06-01
88
-
89
- - Added --force option to login command, to forcefully replace the old auth token
90
- - Added --retry option to publush command, to retry publishing a package multiple times in case of 4xx or 5xx http errors
91
-
92
- ## 4.8.0: 2023-05-01
93
-
94
- - VERSION files now don't need to be trimmed (they can have leading or trailing whitespace characters) in order for commands to read it properly
95
- - Added two new commands (usage in README file):
96
- - download:jmeter-examples
97
- - download:keycloak-scim
98
-
99
- ## 4.7.0: 2023-03-22
100
-
101
- - Fixed bug in `download:studio` when flag `-i` was always required in case we used `-o` flag
102
- - Download of signalr is now also supported
103
- - Improved description for download topic, it now displays information on downloading individual components
104
- - Update command is no longer supported. Instead the update available warning provides information on available update options
105
-
106
- ## 4.6.0: 2023-02-15
107
-
108
- - Doctor no longer checks for `vsts-npm-auth` package
109
- - When installing studio you can pass parameter `s` to skip installation in case the selected version is already installed
110
-
111
- ## 4.5.2: 2023-01-12
112
-
113
- - Limit description length for sql scripts
114
-
115
- ## 4.5.1: 2022-12-13
116
-
117
- - Fixed release version for windows and linux packages
118
-
119
- ## 4.5.0: 2022-10-05
120
-
121
- - Add `--major` flag for sql script generation
122
- - Add `SQL_SCRIPT_VERSION` to force script generation
123
-
124
- ## 4.4.0: 2022-10-03
125
-
126
- - Added parameters for offline sql script creation
127
- - Ability to recover from prerelease tag when creating db scripts
128
-
129
- ## 4.3.0: 2022-07-27
130
-
131
- - Added command `npm:dependency-update` to update dependencies on packages in workspace defined by filter
132
- - Added command `nuget:dependency-update` to update dependencies on packages in workspace defined by filter
133
- - Improve error handling in translation fetching
134
- - Improve warning output when npm publish fails
135
-
136
- ## 4.2.0: 2022-07-15
137
-
138
- - Added command `gitlab:get-tag-pipeline` to track pipeline status and wait for pipeline to finish
139
- - Added `--outputVersionOnly` to `gitlab:next-nightly-tag` to output only version
140
-
141
- ## 4.1.0: 2022-06-15
142
-
143
- - `vsix` file is removed after installation when `-i` flag is used
144
-
145
- ## 4.0.0: 2021-05-31
146
-
147
- - New auth options
148
- - [DEPRECATED] `--servicePrincipal` login is no longer available or required. 'AZURE_CLIENT_ID' and 'AZURE_CLIENT_SECRET' environment variables are required with every command in order to use service principal.
149
-
150
- ## 3.9.0: 2021-05-30
151
-
152
- - Additional options for translations output filename
153
-
154
- ## 3.8.1: 2021-05-17
155
-
156
- - Fix GitLab next nightly tag when tags with `test` and `qa` annotation exists
157
-
158
- ## 3.8.0: 2021-05-05
159
-
160
- - Added GitLab next nightly tag
161
-
162
- ## 3.7.0: 2021-04-28
163
-
164
- - Added download commands for AdInsure Server, Client, IdentityServer and Scheduler
165
-
166
- ## 3.6.1: 2021-12-02
167
-
168
- - Improve workspace search pattern for npm publish
169
-
170
- ## 3.6.0: 2021-11-30
171
-
172
- - Add ability to transform files with prepare-content
173
-
174
- ## 3.5.0: 2021-11-24
175
-
176
- - Renaming prepare-content command
177
-
178
- ## 3.4.0: 2021-10-24
179
-
180
- - Added Jira command for listing labels and setting them
181
- - Added Jira command for listing issue
182
-
183
- ## 3.3.1: 2021-10-16
184
-
185
- - Exclude should be optional for npm:publish
186
-
187
- ## 3.3.0: 2021-10-14
188
-
189
- - Introduced npm check command
190
- - Introcuced npm publish command
191
- - Introduced doctor command
192
- - Introduced download:platform and download:studio command
193
-
194
- ## 3.2.4: 2021-10-09
195
-
196
- - Ignore VERSION file when using 'new' command
197
- - Unexpected token in JSON files should not stop execution
198
- - Introduce `--exclude-dir` parameter for `version` command