@adinsure-ops/ops-cli 5.3.0 → 5.3.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/README.md CHANGED
@@ -21,7 +21,7 @@ To quick start development:
21
21
  - Run `yarn install`
22
22
  - For easier debugging, run `yarn link`
23
23
 
24
- You can run and debug commands directly from terminal by running `ops [command]` (if you `yarn link`-ed the package) or execute `.\bin\run [command]` (if you didn't). For debugging, you can follow oclif's documentation on how to turn on debug mode for a single command **[here](https://oclif.io/docs/debugging/)**.
24
+ You can run and debug commands directly from terminal by running `ops [command]` (if you `yarn link`-ed the package) or execute `.\bin\run [command]` (if you didn't link, e.g. `.\bin\run.cmd sql schema` for non-Windows environments and `.\bin\dev.cmd sql schema` for Windows environments). For debugging, you can follow oclif's documentation on how to turn on debug mode for a single command **[here](https://oclif.io/docs/debugging/)**.
25
25
 
26
26
  ## Upgrade guilde
27
27
 
@@ -7,7 +7,7 @@ export default class DownloadStudio extends CommandBase<typeof DownloadStudio> {
7
7
  static flags: {
8
8
  source: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
9
  version: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
- output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ output: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
11
  install: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
12
12
  skip: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
13
  keep: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
@@ -52,7 +52,7 @@ class DownloadStudio extends CommandBase {
52
52
  installExtension(extensionPath) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  const cp = new ChildProcessCommand();
55
- const commandResult = yield cp.runCommand(['code', '--install-extension', extensionPath, '--force']);
55
+ const commandResult = yield cp.runCommand(['code.cmd', '--install-extension', extensionPath, '--force']);
56
56
  if (commandResult.error) {
57
57
  this.error(`${chalk.redBright('Installing into VSCode failed!')}\n${commandResult.error}`);
58
58
  }
@@ -65,7 +65,7 @@ class DownloadStudio extends CommandBase {
65
65
  return false;
66
66
  }
67
67
  const cp = new ChildProcessCommand();
68
- const result = yield cp.runCommand(['code', '--list-extensions', '--show-versions']);
68
+ const result = yield cp.runCommand(['code.cmd', '--list-extensions', '--show-versions']);
69
69
  return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.includes(studioVersion);
70
70
  });
71
71
  }
@@ -75,16 +75,13 @@ class DownloadStudio extends CommandBase {
75
75
  });
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
77
  _super.run.call(this);
78
+ // Set default based on config, else use './' as final fallback
79
+ const config = new OpsConfig(this.security.getConfigPath());
80
+ const defaultFolder = config.get('download_folder');
81
+ DownloadStudio.flags.output.default = defaultFolder || './';
78
82
  const { flags } = yield this.parse(DownloadStudio);
79
83
  // The os.homedir expands the ~ char, as the node path.resolve method does not expand it
80
84
  let outputDir = flags.output;
81
- if (!outputDir) {
82
- // If the user didn't provide the output flag, try to get the default from config.
83
- const config = new OpsConfig(this.security.getConfigPath());
84
- const defaultFolder = config.get('download_folder');
85
- outputDir = defaultFolder || './'; // no flag -> DEFAULT output is "./"
86
- }
87
- // Expand tilde if present
88
85
  const basePath = outputDir.charAt(0) === '~'
89
86
  ? os.homedir() + outputDir.split('~')[1]
90
87
  : outputDir;
@@ -181,6 +178,7 @@ DownloadStudio.flags = {
181
178
  output: Flags.string({
182
179
  char: 'o',
183
180
  description: 'output directory',
181
+ default: './',
184
182
  }),
185
183
  install: Flags.boolean({
186
184
  char: 'i',
@@ -1,5 +1,6 @@
1
1
  import CommandBase from '../../command.base.js';
2
2
  import GitLab from '../../lib/gitlab.js';
3
+ import OpsConfig from '../../lib/config.js';
3
4
  export default class GitlabGetTagPipeline extends CommandBase<typeof GitlabGetTagPipeline> {
4
5
  static description: string;
5
6
  static usage: string;
@@ -16,5 +17,7 @@ export default class GitlabGetTagPipeline extends CommandBase<typeof GitlabGetTa
16
17
  delay: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
18
  };
18
19
  waitPipelineStatus(gitlab: GitLab, tag: string, timeout: number, delay: number): Promise<string>;
20
+ hostConfigValidation(config: OpsConfig): Promise<void>;
21
+ projectConfigValidation(config: OpsConfig): Promise<void>;
19
22
  run(): Promise<void>;
20
23
  }
@@ -3,6 +3,7 @@ import { Args, Flags } from '@oclif/core';
3
3
  import chalk from 'chalk';
4
4
  import CommandBase from '../../command.base.js';
5
5
  import GitLab from '../../lib/gitlab.js';
6
+ import OpsConfig from '../../lib/config.js';
6
7
  class GitlabGetTagPipeline extends CommandBase {
7
8
  waitPipelineStatus(gitlab, tag, timeout, delay) {
8
9
  return __awaiter(this, void 0, void 0, function* () {
@@ -82,12 +83,36 @@ class GitlabGetTagPipeline extends CommandBase {
82
83
  }));
83
84
  });
84
85
  }
86
+ hostConfigValidation(config) {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const host = config.get("gitlab_host");
89
+ if (host !== undefined) {
90
+ GitlabGetTagPipeline.flags.host.default = host;
91
+ return;
92
+ }
93
+ GitlabGetTagPipeline.flags.host.default =
94
+ "https://git.adacta-fintech.com";
95
+ });
96
+ }
97
+ projectConfigValidation(config) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const project = config.get("gitlab_project_id");
100
+ if (project !== undefined) {
101
+ GitlabGetTagPipeline.flags.project.default = project;
102
+ return;
103
+ }
104
+ GitlabGetTagPipeline.flags.project.default = "413";
105
+ });
106
+ }
85
107
  run() {
86
108
  const _super = Object.create(null, {
87
109
  run: { get: () => super.run }
88
110
  });
89
111
  return __awaiter(this, void 0, void 0, function* () {
90
112
  _super.run.call(this);
113
+ const config = new OpsConfig(this.security.getConfigPath());
114
+ this.hostConfigValidation(config);
115
+ this.projectConfigValidation(config);
91
116
  const { args, flags } = yield this.parse(GitlabGetTagPipeline);
92
117
  const gitlab = new GitLab(flags.host, flags.project, flags.pat);
93
118
  if (!flags.wait) {
@@ -123,13 +148,11 @@ GitlabGetTagPipeline.flags = {
123
148
  description: 'Token from user that has permissions to list and create tags',
124
149
  }),
125
150
  host: Flags.string({
126
- required: true,
127
151
  default: 'https://git.adacta-fintech.com',
128
152
  env: 'CI_SERVER_URL',
129
153
  description: 'Server hostname',
130
154
  }),
131
155
  project: Flags.string({
132
- required: true,
133
156
  default: '413',
134
157
  env: 'CI_PROJECT_ID',
135
158
  description: 'Project ID',
@@ -1,4 +1,5 @@
1
1
  import CommandBase from '../../command.base.js';
2
+ import OpsConfig from '../../lib/config.js';
2
3
  export default class GitlabNextNightlyTag extends CommandBase<typeof GitlabNextNightlyTag> {
3
4
  static description: string;
4
5
  static usage: string;
@@ -14,5 +15,7 @@ export default class GitlabNextNightlyTag extends CommandBase<typeof GitlabNextN
14
15
  outputVersionOnly: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
15
16
  dryRun: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
16
17
  };
18
+ hostConfigValidation(config: OpsConfig): Promise<void>;
19
+ projectConfigValidation(config: OpsConfig): Promise<void>;
17
20
  run(): Promise<undefined>;
18
21
  }
@@ -4,13 +4,38 @@ import chalk from 'chalk';
4
4
  import semver from 'semver';
5
5
  import CommandBase from '../../command.base.js';
6
6
  import GitLab from '../../lib/gitlab.js';
7
+ import OpsConfig from '../../lib/config.js';
7
8
  class GitlabNextNightlyTag extends CommandBase {
9
+ hostConfigValidation(config) {
10
+ return __awaiter(this, void 0, void 0, function* () {
11
+ const host = config.get("gitlab_host");
12
+ if (host !== undefined) {
13
+ GitlabNextNightlyTag.flags.host.default = host;
14
+ return;
15
+ }
16
+ GitlabNextNightlyTag.flags.host.default =
17
+ "https://git.adacta-fintech.com";
18
+ });
19
+ }
20
+ projectConfigValidation(config) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const project = config.get("gitlab_project_id");
23
+ if (project !== undefined) {
24
+ GitlabNextNightlyTag.flags.project.default = project;
25
+ return;
26
+ }
27
+ GitlabNextNightlyTag.flags.project.default = "413";
28
+ });
29
+ }
8
30
  run() {
9
31
  const _super = Object.create(null, {
10
32
  run: { get: () => super.run }
11
33
  });
12
34
  return __awaiter(this, void 0, void 0, function* () {
13
35
  _super.run.call(this);
36
+ const config = new OpsConfig(this.security.getConfigPath());
37
+ this.hostConfigValidation(config);
38
+ this.projectConfigValidation(config);
14
39
  const { args, flags } = yield this.parse(GitlabNextNightlyTag);
15
40
  const gitlab = new GitLab(flags.host, flags.project, flags.pat);
16
41
  const re = /^release\/(\w+-)?((\d+)(\.\d+)?)$/;
@@ -103,13 +128,11 @@ GitlabNextNightlyTag.flags = {
103
128
  description: 'Token from user that has permissions to list and create tags',
104
129
  }),
105
130
  host: Flags.string({
106
- required: true,
107
131
  default: 'https://git.adacta-fintech.com',
108
132
  env: 'CI_SERVER_URL',
109
133
  description: 'Server hostname',
110
134
  }),
111
135
  project: Flags.string({
112
- required: true,
113
136
  default: '413',
114
137
  env: 'CI_PROJECT_ID',
115
138
  description: 'Project ID',
@@ -15,7 +15,14 @@ export default class Generate extends CommandBase<typeof Generate> {
15
15
  };
16
16
  private readonly _entryTypes;
17
17
  private readonly _mdFileTypeRegex;
18
+ private readonly _changelogTitle;
18
19
  readChangelogs(dir: string): Promise<ChangelogEntry[]>;
19
- generateLog(entries: ChangelogEntry[], components: string[]): Promise<string>;
20
+ generateLog(entries: ChangelogEntry[], components: string[], headingLevel?: number): Promise<string>;
21
+ generateChangelog(version: string, entries: ChangelogEntry[], components: string[], currentContents?: string, date?: string): Promise<string>;
22
+ private formatEntry;
23
+ private indentMarkdownLines;
24
+ private stripChangelogTitle;
25
+ private normalizeLineEndings;
26
+ private startsWithBlockContent;
20
27
  run(): Promise<void>;
21
28
  }
@@ -18,6 +18,7 @@ class Generate extends CommandBase {
18
18
  { types: ['Fixed', 'fixed'], text: 'Fixed' },
19
19
  ];
20
20
  this._mdFileTypeRegex = /\.md$/i;
21
+ this._changelogTitle = '# Changelog';
21
22
  }
22
23
  readChangelogs(dir) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -38,43 +39,84 @@ class Generate extends CommandBase {
38
39
  return result;
39
40
  });
40
41
  }
41
- generateLog(entries, components) {
42
- return __awaiter(this, void 0, void 0, function* () {
42
+ generateLog(entries_1, components_1) {
43
+ return __awaiter(this, arguments, void 0, function* (entries, components, headingLevel = 3) {
44
+ var _a;
43
45
  let content = '';
44
46
  // First group by component, then re-sort the components to get the desired output ordering
45
47
  const componentGroups = _.groupBy(entries, 'component');
46
48
  for (const group of components) {
49
+ const groupEntries = (_a = componentGroups[group]) !== null && _a !== void 0 ? _a : [];
47
50
  if (group !== '') {
48
- content += `## ${_.capitalize(group)}\r\n\r\n`;
51
+ content += `${'#'.repeat(headingLevel)} ${_.capitalize(group)}\r\n\r\n`;
49
52
  }
50
- if (componentGroups[group] === undefined || componentGroups[group].length === 0) {
53
+ if (groupEntries.length === 0) {
51
54
  content += `No changes were introduced in this version.\r\n\r\n`;
52
55
  continue;
53
56
  }
57
+ const typeHeadingLevel = group === '' ? headingLevel : headingLevel + 1;
54
58
  for (const type of this._entryTypes) {
55
- const batch = _.remove(componentGroups[group], e => _.indexOf(type.types, e.type) > -1);
59
+ const batch = groupEntries.filter(e => _.indexOf(type.types, e.type) > -1);
56
60
  if (batch.length === 0) {
57
61
  continue;
58
62
  }
59
- content += `### ${type.text} (${batch.length} changes)\r\n\r\n`;
63
+ content += `${'#'.repeat(typeHeadingLevel)} ${type.text} (${batch.length} changes)\r\n\r\n`;
60
64
  for (const log of batch) {
61
- if (log.content.startsWith('-') || log.content.startsWith('* ')) {
62
- content += `- [${log.issue}](https://jira.adacta-fintech.com/browse/${log.issue}):\r\n`;
63
- content += ' ' + log.content.replaceAll('\n', '\n ');
64
- }
65
- else {
66
- content += `- [${log.issue}](https://jira.adacta-fintech.com/browse/${log.issue}): `;
67
- content += log.content.replaceAll('\n', '\n ') + '\r\n';
68
- }
69
- content += '\r\n';
65
+ content += `${this.formatEntry(log)}\r\n\r\n`;
70
66
  }
71
- content += '\r\n';
72
67
  }
73
68
  }
74
69
  // We only want 1 new line at the end of this changelog
75
- return content.trimEnd() + '\r\n\r\n';
70
+ return content.trimEnd() + '\r\n';
71
+ });
72
+ }
73
+ generateChangelog(version_1, entries_1, components_1) {
74
+ return __awaiter(this, arguments, void 0, function* (version, entries, components, currentContents = '', date = moment().format('YYYY-MM-DD')) {
75
+ const currentChangelog = this.stripChangelogTitle(currentContents);
76
+ const generatedChangelog = `${this._changelogTitle}\r\n\r\n## ${version} (${date})\r\n\r\n${yield this.generateLog(entries, components)}`;
77
+ return currentChangelog ? `${generatedChangelog}\r\n${currentChangelog}\r\n` : generatedChangelog;
76
78
  });
77
79
  }
80
+ formatEntry(log) {
81
+ const normalizedContent = this.normalizeLineEndings(log.content).trim();
82
+ const lines = normalizedContent.length === 0 ? [] : normalizedContent.split('\n').map(line => line.trimEnd());
83
+ const issueLine = `- [${log.issue}](https://jira.adacta-fintech.com/browse/${log.issue}):`;
84
+ if (lines.length === 0) {
85
+ return issueLine;
86
+ }
87
+ if (this.startsWithBlockContent(lines[0])) {
88
+ return `${issueLine}\r\n${this.indentMarkdownLines(lines)}`;
89
+ }
90
+ const [firstLine, ...remainingLines] = lines;
91
+ if (remainingLines.length === 0) {
92
+ return `${issueLine} ${firstLine}`;
93
+ }
94
+ return `${issueLine} ${firstLine}\r\n${this.indentMarkdownLines(remainingLines)}`;
95
+ }
96
+ indentMarkdownLines(lines) {
97
+ return lines.map(line => line.length === 0 ? '' : ` ${line}`).join('\r\n');
98
+ }
99
+ stripChangelogTitle(currentContents) {
100
+ const trimmedContents = currentContents.trimEnd();
101
+ if (trimmedContents.length === 0) {
102
+ return '';
103
+ }
104
+ const lines = this.normalizeLineEndings(trimmedContents.trimStart()).split('\n');
105
+ if (lines[0].trim().toLowerCase() !== this._changelogTitle.toLowerCase()) {
106
+ return trimmedContents;
107
+ }
108
+ lines.shift();
109
+ while (lines.length > 0 && lines[0].trim().length === 0) {
110
+ lines.shift();
111
+ }
112
+ return lines.join('\r\n').trimEnd();
113
+ }
114
+ normalizeLineEndings(content) {
115
+ return content.replace(/\r\n?/g, '\n');
116
+ }
117
+ startsWithBlockContent(line) {
118
+ return /^([-*+]\s|\d+\.\s|```|~~~|\||#{1,6}\s)/.test(line.trimStart());
119
+ }
78
120
  run() {
79
121
  const _super = Object.create(null, {
80
122
  run: { get: () => super.run }
@@ -94,9 +136,8 @@ class Generate extends CommandBase {
94
136
  ux.action.stop('done, no changelogs found.');
95
137
  return;
96
138
  }
97
- const content = `# ${version} (${moment().format('YYYY-MM-DD')})\r\n\r\n${yield this.generateLog(changelogs, components)}`;
98
139
  if (flags.preview) {
99
- fs.writeFileSync(path.resolve(root, 'preview.md'), content, 'utf8');
140
+ fs.writeFileSync(path.resolve(root, 'preview.md'), yield this.generateChangelog(version, changelogs, components), 'utf8');
100
141
  ux.action.stop('generated preview.md');
101
142
  return;
102
143
  }
@@ -105,7 +146,7 @@ class Generate extends CommandBase {
105
146
  if (confirm) {
106
147
  const changelogFile = path.resolve(root, flags.file);
107
148
  const currentContents = fs.readFileSync(changelogFile, { encoding: 'utf8', flag: 'a+' });
108
- fs.writeFileSync(changelogFile, content + currentContents, { encoding: 'utf8', flag: 'w' });
149
+ fs.writeFileSync(changelogFile, yield this.generateChangelog(version, changelogs, components, currentContents), { encoding: 'utf8', flag: 'w' });
109
150
  // delete unreleased changelogs
110
151
  for (const group of components) {
111
152
  const componentChangelogFolder = path.join(changelogFolder, group);
@@ -15,7 +15,9 @@ export default class NpmPublish extends CommandBase<typeof NpmPublish> {
15
15
  publishPackage(pkg: NpmPackage, cmd?: string[]): Promise<{
16
16
  data: string;
17
17
  error: string;
18
+ exitCode: unknown;
18
19
  }>;
20
+ wasPublished(data: string, error: string, exitCode: unknown): Promise<boolean>;
19
21
  checkPackageCanPublish(pkg: NpmPackage, allPackages: AzurePackageArray, version: string, retries: number): Promise<boolean>;
20
22
  publishPackages(packages: NpmPackage[], allPackages: AzurePackageArray, version: string, retries: number): Promise<void>;
21
23
  run(): Promise<void>;
@@ -18,56 +18,61 @@ class NpmPublish extends CommandBase {
18
18
  else {
19
19
  [sh, ...args] = cmd;
20
20
  }
21
+ this.cp = spawn(sh, args, {
22
+ cwd: pkg.path,
23
+ env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
24
+ stdio: 'pipe',
25
+ });
26
+ let data = '';
21
27
  try {
22
- this.cp = spawn(sh, args, {
23
- cwd: pkg.path,
24
- env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
25
- stdio: 'pipe',
26
- });
27
- let data = '';
28
- try {
29
- for (var _g = true, _h = __asyncValues(this.cp.stdout), _j; _j = yield _h.next(), _a = _j.done, !_a; _g = true) {
30
- _c = _j.value;
31
- _g = false;
32
- const chunk = _c;
33
- data += chunk;
34
- }
35
- }
36
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
37
- finally {
38
- try {
39
- if (!_g && !_a && (_b = _h.return)) yield _b.call(_h);
40
- }
41
- finally { if (e_1) throw e_1.error; }
28
+ for (var _g = true, _h = __asyncValues(this.cp.stdout), _j; _j = yield _h.next(), _a = _j.done, !_a; _g = true) {
29
+ _c = _j.value;
30
+ _g = false;
31
+ const chunk = _c;
32
+ data += chunk;
42
33
  }
43
- let error = '';
34
+ }
35
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36
+ finally {
44
37
  try {
45
- for (var _k = true, _l = __asyncValues(this.cp.stderr), _m; _m = yield _l.next(), _d = _m.done, !_d; _k = true) {
46
- _f = _m.value;
47
- _k = false;
48
- const chunk = _f;
49
- error += chunk;
50
- }
38
+ if (!_g && !_a && (_b = _h.return)) yield _b.call(_h);
51
39
  }
52
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
53
- finally {
54
- try {
55
- if (!_k && !_d && (_e = _l.return)) yield _e.call(_l);
56
- }
57
- finally { if (e_2) throw e_2.error; }
40
+ finally { if (e_1) throw e_1.error; }
41
+ }
42
+ let error = '';
43
+ try {
44
+ for (var _k = true, _l = __asyncValues(this.cp.stderr), _m; _m = yield _l.next(), _d = _m.done, !_d; _k = true) {
45
+ _f = _m.value;
46
+ _k = false;
47
+ const chunk = _f;
48
+ error += chunk;
58
49
  }
59
- const exitCode = yield new Promise((resolve) => {
60
- this.cp.on('close', resolve);
61
- });
62
- if (exitCode) {
63
- throw new Error(`subprocess error exit ${exitCode}, ${error}`);
50
+ }
51
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
52
+ finally {
53
+ try {
54
+ if (!_k && !_d && (_e = _l.return)) yield _e.call(_l);
64
55
  }
65
- return { data, error };
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ finally { if (e_2) throw e_2.error; }
67
57
  }
68
- catch (error) {
69
- throw new Error(error.message);
58
+ const exitCode = yield new Promise((resolve) => {
59
+ this.cp.on('close', resolve);
60
+ });
61
+ return { data, error, exitCode };
62
+ });
63
+ }
64
+ wasPublished(data, error, exitCode) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ if (exitCode) {
67
+ return false;
68
+ }
69
+ // Extract the HTTP status code from the error message
70
+ const statusCodeMatch = /\d{3}/.exec(error);
71
+ const statusCode = statusCodeMatch ? Number.parseInt(statusCodeMatch[0], 10) : null;
72
+ if (statusCode && (statusCode >= 400 && statusCode < 600)) {
73
+ return false;
70
74
  }
75
+ return true;
71
76
  });
72
77
  }
73
78
  checkPackageCanPublish(pkg, allPackages, version, retries) {
@@ -83,22 +88,17 @@ class NpmPublish extends CommandBase {
83
88
  if (!matchedPackage) {
84
89
  ux.action.stop(`${chalk.green('new package')}`);
85
90
  ux.action.start(`publish new package ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
86
- try {
87
- yield this.publishPackage(pkg);
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- }
90
- catch (error) {
91
- if (error instanceof Error && error.message.includes('subprocess error exit')) {
92
- // Check if the error message contains 'subprocess error exit'
93
- // Extract the HTTP status code from the error message
94
- const statusCodeMatch = /\d{3}/.exec(error.message);
95
- const statusCode = statusCodeMatch ? Number.parseInt(statusCodeMatch[0], 10) : null;
96
- if (statusCode && (statusCode >= 400 && statusCode < 600)) {
97
- for (let i = 0; i < retries - 1; i++) {
98
- yield this.publishPackage(pkg);
99
- }
100
- }
91
+ let published = false;
92
+ for (let i = 0; i < retries - 1; i++) {
93
+ const { data, error, exitCode } = yield this.publishPackage(pkg);
94
+ if (!this.wasPublished(data, error, exitCode)) {
95
+ continue;
101
96
  }
97
+ published = true;
98
+ break;
99
+ }
100
+ if (!published) {
101
+ throw new Error(`publishing of ${pkg.name}@${pkg.version} failed`);
102
102
  }
103
103
  ux.action.stop(`${chalk.green('done')}`);
104
104
  return true;
@@ -107,7 +107,10 @@ class NpmPublish extends CommandBase {
107
107
  if (!matchVersion) {
108
108
  ux.action.stop(`${chalk.yellow('version missing')}`);
109
109
  ux.action.start(`publish new version ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
110
- yield this.publishPackage(pkg);
110
+ const { data, error, exitCode } = yield this.publishPackage(pkg);
111
+ if (!this.wasPublished(data, error, exitCode)) {
112
+ throw new Error(`publishing of ${pkg.name}@${pkg.version} failed`);
113
+ }
111
114
  ux.action.stop(`${chalk.green('done')}`);
112
115
  return true;
113
116
  }
@@ -18,6 +18,7 @@ export default class Sql extends CommandBase<typeof Sql> {
18
18
  'table-name': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
19
19
  'column-name': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
20
20
  'column-type': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
21
+ dwh: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
21
22
  };
22
23
  private readonly _moduleTypes;
23
24
  private _dbmsTypes;
@@ -237,7 +237,8 @@ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
237
237
  }
238
238
  const scriptLayer = flags.layer;
239
239
  this.log(`Generating on SQL script layer:'${scriptLayer}'`);
240
- const scriptsRootFolder = path.resolve(yield this.getGitRoot(), 'database');
240
+ const databaseFolder = flags.dwh ? 'database-dwh' : 'database';
241
+ const scriptsRootFolder = path.resolve(yield this.getGitRoot(), databaseFolder);
241
242
  if (!(yield fs.pathExists(scriptsRootFolder))) {
242
243
  this.error(`Could not resolve database scripts folder: ${scriptsRootFolder}`);
243
244
  }
@@ -282,8 +283,12 @@ ADD COLUMN IF NOT EXISTS ${columnName} ${columnType};
282
283
  Sql.description = 'creates a new database script';
283
284
  Sql.usage = 'sql <type> <module> [flags]';
284
285
  Sql.examples = [
285
- `$ ops sql schema `,
286
+ `$ ops sql schema`,
287
+ `$ ops sql schema --dwh`,
288
+ `$ ops sql data acc`,
289
+ `$ ops sql data acc --dwh`,
286
290
  `$ ops sql data shared --layer basic`,
291
+ `$ ops sql data shared --dwh --layer basic`,
287
292
  `$ ops sql data shared --major`,
288
293
  `$ ops sql data shared --offline --description "this is script description"`,
289
294
  ];
@@ -335,5 +340,9 @@ Sql.flags = {
335
340
  'column-type': Flags.string({
336
341
  description: 'type of the new column to be added',
337
342
  }),
343
+ 'dwh': Flags.boolean({
344
+ description: 'create database scripts for DWH',
345
+ default: false
346
+ }),
338
347
  };
339
348
  export default Sql;
@@ -210,8 +210,12 @@
210
210
  },
211
211
  "description": "creates a new database script",
212
212
  "examples": [
213
- "$ ops sql schema ",
213
+ "$ ops sql schema",
214
+ "$ ops sql schema --dwh",
215
+ "$ ops sql data acc",
216
+ "$ ops sql data acc --dwh",
214
217
  "$ ops sql data shared --layer basic",
218
+ "$ ops sql data shared --dwh --layer basic",
215
219
  "$ ops sql data shared --major",
216
220
  "$ ops sql data shared --offline --description \"this is script description\""
217
221
  ],
@@ -284,6 +288,12 @@
284
288
  "hasDynamicHelp": false,
285
289
  "multiple": false,
286
290
  "type": "option"
291
+ },
292
+ "dwh": {
293
+ "description": "create database scripts for DWH",
294
+ "name": "dwh",
295
+ "allowNo": false,
296
+ "type": "boolean"
287
297
  }
288
298
  },
289
299
  "hasDynamicHelp": false,
@@ -1095,6 +1105,7 @@
1095
1105
  "char": "o",
1096
1106
  "description": "output directory",
1097
1107
  "name": "output",
1108
+ "default": "./",
1098
1109
  "hasDynamicHelp": false,
1099
1110
  "multiple": false,
1100
1111
  "type": "option"
@@ -1180,7 +1191,6 @@
1180
1191
  "description": "Server hostname",
1181
1192
  "env": "CI_SERVER_URL",
1182
1193
  "name": "host",
1183
- "required": true,
1184
1194
  "default": "https://git.adacta-fintech.com",
1185
1195
  "hasDynamicHelp": false,
1186
1196
  "multiple": false,
@@ -1190,7 +1200,6 @@
1190
1200
  "description": "Project ID",
1191
1201
  "env": "CI_PROJECT_ID",
1192
1202
  "name": "project",
1193
- "required": true,
1194
1203
  "default": "413",
1195
1204
  "hasDynamicHelp": false,
1196
1205
  "multiple": false,
@@ -1262,7 +1271,6 @@
1262
1271
  "description": "Server hostname",
1263
1272
  "env": "CI_SERVER_URL",
1264
1273
  "name": "host",
1265
- "required": true,
1266
1274
  "default": "https://git.adacta-fintech.com",
1267
1275
  "hasDynamicHelp": false,
1268
1276
  "multiple": false,
@@ -1272,7 +1280,6 @@
1272
1280
  "description": "Project ID",
1273
1281
  "env": "CI_PROJECT_ID",
1274
1282
  "name": "project",
1275
- "required": true,
1276
1283
  "default": "413",
1277
1284
  "hasDynamicHelp": false,
1278
1285
  "multiple": false,
@@ -1852,5 +1859,5 @@
1852
1859
  ]
1853
1860
  }
1854
1861
  },
1855
- "version": "5.3.0"
1862
+ "version": "5.3.2"
1856
1863
  }
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "name": "@adinsure-ops/ops-cli",
3
3
  "description": "Operations CLI for working with AdInsure",
4
- "version": "5.3.0",
4
+ "version": "5.3.2",
5
5
  "author": "Adacta Digital Service Department",
6
6
  "bin": {
7
7
  "ops": "./bin/run.js"
8
8
  },
9
9
  "type": "module",
10
10
  "dependencies": {
11
- "@azure/msal-node": "^2.8.1",
12
- "@oclif/core": "^3.26.6",
13
- "@oclif/plugin-help": "^6.0.22",
14
- "@oclif/plugin-not-found": "^3.1.9",
15
- "@oclif/plugin-warn-if-update-available": "^3.0.19",
16
- "axios": "^1.6.8",
17
- "chalk": "^5.3.0",
18
- "fs-extra": "^11.2.0",
19
- "globby": "^14.0.1",
20
- "gray-matter": "^4.0.3",
21
- "ini": "^4.1.2",
22
- "inquirer": "^9.2.21",
11
+ "@azure/msal-node": "2.8.1",
12
+ "@oclif/core": "3.26.6",
13
+ "@oclif/plugin-help": "6.0.22",
14
+ "@oclif/plugin-not-found": "3.1.9",
15
+ "@oclif/plugin-warn-if-update-available": "3.0.19",
16
+ "axios": "1.14.0",
17
+ "chalk": "5.3.0",
18
+ "fs-extra": "11.2.0",
19
+ "globby": "14.0.1",
20
+ "gray-matter": "4.0.3",
21
+ "ini": "4.1.2",
22
+ "inquirer": "9.2.21",
23
23
  "jira-client": "8.2.2",
24
- "jszip": "^3.10.1",
25
- "lodash-es": "^4.17.21",
26
- "minimatch": "^9.0.4",
27
- "moment": "^2.30.1",
28
- "oauth": "^0.10.0",
29
- "open": "^10.1.0",
30
- "replace-in-file": "^7.1.0",
31
- "rimraf": "^5.0.7",
32
- "semver": "^7.6.2",
33
- "tough-cookie": "^4.1.4",
34
- "tslib": "^2.6.2",
35
- "yaml": "^2.4.2"
24
+ "jszip": "3.10.1",
25
+ "lodash-es": "4.17.21",
26
+ "minimatch": "9.0.4",
27
+ "moment": "2.30.1",
28
+ "oauth": "0.10.0",
29
+ "open": "10.1.0",
30
+ "replace-in-file": "7.1.0",
31
+ "rimraf": "5.0.7",
32
+ "semver": "7.6.2",
33
+ "tough-cookie": "4.1.4",
34
+ "tslib": "2.6.2",
35
+ "yaml": "2.4.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@eslint/js": "^9.2.0",
@@ -122,5 +122,8 @@
122
122
  "test-single-with-coverage": "nyc --require ts-node/register --extension .ts mocha --reporter=doc --timeout 20000 --forbid-only",
123
123
  "eslint": "eslint --quiet --config .eslint.config.js --fix"
124
124
  },
125
- "types": "lib/index.d.ts"
125
+ "types": "lib/index.d.ts",
126
+ "resolutions": {
127
+ "axios": "1.14.0"
128
+ }
126
129
  }