@adinsure-ops/ops-cli 4.0.0-rc10

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 (71) hide show
  1. package/CHANGELOGS.md +56 -0
  2. package/LICENSE +1 -0
  3. package/README.md +725 -0
  4. package/bin/run +5 -0
  5. package/bin/run.cmd +3 -0
  6. package/lib/command.base.d.ts +17 -0
  7. package/lib/command.base.jira.d.ts +11 -0
  8. package/lib/command.base.jira.js +37 -0
  9. package/lib/command.base.js +73 -0
  10. package/lib/commands/doctor.d.ts +54 -0
  11. package/lib/commands/doctor.js +311 -0
  12. package/lib/commands/download/client.d.ts +17 -0
  13. package/lib/commands/download/client.js +71 -0
  14. package/lib/commands/download/identity-server.d.ts +17 -0
  15. package/lib/commands/download/identity-server.js +71 -0
  16. package/lib/commands/download/platform.d.ts +18 -0
  17. package/lib/commands/download/platform.js +72 -0
  18. package/lib/commands/download/scheduler.d.ts +17 -0
  19. package/lib/commands/download/scheduler.js +71 -0
  20. package/lib/commands/download/server.d.ts +17 -0
  21. package/lib/commands/download/server.js +71 -0
  22. package/lib/commands/download/studio.d.ts +19 -0
  23. package/lib/commands/download/studio.js +88 -0
  24. package/lib/commands/gitlab/next-nightly-tag.d.ts +29 -0
  25. package/lib/commands/gitlab/next-nightly-tag.js +169 -0
  26. package/lib/commands/jira/issue.d.ts +17 -0
  27. package/lib/commands/jira/issue.js +31 -0
  28. package/lib/commands/jira/labels.d.ts +22 -0
  29. package/lib/commands/jira/labels.js +70 -0
  30. package/lib/commands/log/add.d.ts +17 -0
  31. package/lib/commands/log/add.js +107 -0
  32. package/lib/commands/log/generate.d.ts +22 -0
  33. package/lib/commands/log/generate.js +155 -0
  34. package/lib/commands/log/validate.d.ts +11 -0
  35. package/lib/commands/log/validate.js +58 -0
  36. package/lib/commands/login.d.ts +24 -0
  37. package/lib/commands/login.js +154 -0
  38. package/lib/commands/npm/check-publish.d.ts +16 -0
  39. package/lib/commands/npm/check-publish.js +77 -0
  40. package/lib/commands/npm/publish.d.ts +22 -0
  41. package/lib/commands/npm/publish.js +162 -0
  42. package/lib/commands/prepare-content.d.ts +29 -0
  43. package/lib/commands/prepare-content.js +386 -0
  44. package/lib/commands/sql.d.ts +24 -0
  45. package/lib/commands/sql.js +147 -0
  46. package/lib/commands/translate.d.ts +37 -0
  47. package/lib/commands/translate.js +149 -0
  48. package/lib/commands/version.d.ts +48 -0
  49. package/lib/commands/version.js +267 -0
  50. package/lib/config.d.ts +7 -0
  51. package/lib/config.js +9 -0
  52. package/lib/hooks/init/version-override.d.ts +2 -0
  53. package/lib/hooks/init/version-override.js +15 -0
  54. package/lib/index.d.ts +1 -0
  55. package/lib/index.js +4 -0
  56. package/lib/lib/command.d.ts +9 -0
  57. package/lib/lib/command.js +71 -0
  58. package/lib/lib/npm.d.ts +15 -0
  59. package/lib/lib/npm.js +79 -0
  60. package/lib/lib/npmrc.d.ts +17 -0
  61. package/lib/lib/npmrc.js +44 -0
  62. package/lib/security/cache.d.ts +7 -0
  63. package/lib/security/cache.js +33 -0
  64. package/lib/security/context.d.ts +58 -0
  65. package/lib/security/context.js +228 -0
  66. package/lib/types/changelog.types.d.ts +6 -0
  67. package/lib/types/changelog.types.js +2 -0
  68. package/lib/types/npm.types.d.ts +34 -0
  69. package/lib/types/npm.types.js +2 -0
  70. package/oclif.manifest.json +1 -0
  71. package/package.json +116 -0
@@ -0,0 +1,16 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../../command.base';
3
+ import { AzurePackageArray, NpmPackage } from '../../types/npm.types';
4
+ export default class NpmCheckPublish extends CommandBase {
5
+ static description: string;
6
+ static usage: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ package: flags.IOptionFlag<string[]>;
10
+ exclude: flags.IOptionFlag<string[]>;
11
+ version: flags.IOptionFlag<string>;
12
+ pat: flags.IOptionFlag<string | undefined>;
13
+ };
14
+ checkPackagesExists(packages: NpmPackage[], allPackages: AzurePackageArray, version: string): Promise<void>;
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@oclif/command");
4
+ const chalk_1 = require("chalk");
5
+ const cli_ux_1 = require("cli-ux");
6
+ const command_base_1 = require("../../command.base");
7
+ const npm_1 = require("../../lib/npm");
8
+ class NpmCheckPublish extends command_base_1.default {
9
+ async checkPackagesExists(packages, allPackages, version) {
10
+ let errorCount = 0;
11
+ for (const pkg of packages) {
12
+ cli_ux_1.default.action.start(`${pkg.name}@${version}`, undefined, { stdout: true });
13
+ let matchedPackage = allPackages.value.find(azurePackage => azurePackage.name === pkg.name);
14
+ if (!matchedPackage) {
15
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('package missing')}`);
16
+ errorCount++;
17
+ continue;
18
+ }
19
+ let matchVersion = matchedPackage.versions.find(azurePackageVersion => azurePackageVersion.version === version);
20
+ if (!matchVersion) {
21
+ cli_ux_1.default.action.stop(`${chalk_1.default.red('version missing')}`);
22
+ errorCount++;
23
+ continue;
24
+ }
25
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('exists')}`);
26
+ }
27
+ if (errorCount > 0) {
28
+ throw new Error(`${errorCount} packages or versions missing!`);
29
+ }
30
+ }
31
+ async run() {
32
+ try {
33
+ const { flags } = this.parse(NpmCheckPublish);
34
+ let npmContext = new npm_1.default();
35
+ cli_ux_1.default.action.start('Parsing packages to check', undefined, { stdout: true });
36
+ const packages = await npmContext.packageList(flags.package, flags.exclude, this);
37
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
38
+ cli_ux_1.default.action.start('Getting list of available packages', undefined, { stdout: true });
39
+ const allPackages = JSON.parse(await npmContext.getAllNpmPackages(flags.pat));
40
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
41
+ await this.checkPackagesExists(packages, allPackages, flags.version);
42
+ cli_ux_1.default.action.stop('success');
43
+ }
44
+ catch (err) {
45
+ cli_ux_1.default.action.stop('error');
46
+ this.error(`${err.message}`);
47
+ }
48
+ }
49
+ }
50
+ exports.default = NpmCheckPublish;
51
+ NpmCheckPublish.description = 'check if npm packages were published';
52
+ NpmCheckPublish.usage = 'npm:check-publish [options]';
53
+ NpmCheckPublish.examples = [
54
+ '$ ops npm:check-publish -v 6.0.1',
55
+ '$ ops npm:check-publish -p @adinsure/* -v 6.0.0',
56
+ '$ ops npm:check-publish -p @adinsure/* -x @adisure/demo -v 6.0.0'
57
+ ];
58
+ NpmCheckPublish.flags = {
59
+ package: command_1.flags.string({
60
+ char: 'p',
61
+ description: 'package name filter you want to check',
62
+ multiple: true
63
+ }),
64
+ exclude: command_1.flags.string({
65
+ char: 'x',
66
+ description: 'exclude packages from filter',
67
+ multiple: true
68
+ }),
69
+ version: command_1.flags.string({
70
+ char: 'v',
71
+ description: 'version we want to check if published',
72
+ required: true
73
+ }),
74
+ pat: command_1.flags.string({
75
+ description: 'PAT token or AZURE_DEVOPS_EXT_PAT environment variable'
76
+ }),
77
+ };
@@ -0,0 +1,22 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../../command.base';
3
+ import { AzurePackageArray, NpmPackage } from '../../types/npm.types';
4
+ export default class NpmPublish extends CommandBase {
5
+ static description: string;
6
+ static usage: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ package: flags.IOptionFlag<string[]>;
10
+ exclude: flags.IOptionFlag<string[]>;
11
+ version: flags.IOptionFlag<string>;
12
+ pat: flags.IOptionFlag<string | undefined>;
13
+ };
14
+ private cp;
15
+ publishPackage(pkg: NpmPackage, cmd?: string[]): Promise<{
16
+ data: string;
17
+ error: string;
18
+ }>;
19
+ checkPackageCanPublish(pkg: NpmPackage, allPackages: AzurePackageArray, version: string): Promise<boolean>;
20
+ publishPackages(packages: NpmPackage[], allPackages: AzurePackageArray, version: string): Promise<void>;
21
+ run(): Promise<void>;
22
+ }
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const command_1 = require("@oclif/command");
5
+ const chalk_1 = require("chalk");
6
+ const child_process_1 = require("child_process");
7
+ const cli_ux_1 = require("cli-ux");
8
+ const command_base_1 = require("../../command.base");
9
+ const npm_1 = require("../../lib/npm");
10
+ class NpmPublish extends command_base_1.default {
11
+ async publishPackage(pkg, cmd = ['yarn', 'publish']) {
12
+ var e_1, _a, e_2, _b;
13
+ let sh;
14
+ let args;
15
+ // cross platform compatibility
16
+ if (process.platform === 'win32') {
17
+ sh = 'cmd';
18
+ args = ['/c'].concat(cmd);
19
+ }
20
+ else {
21
+ [sh, ...args] = cmd;
22
+ }
23
+ try {
24
+ this.cp = child_process_1.spawn(sh, args, {
25
+ cwd: pkg.path,
26
+ env: Object.assign(Object.assign({}, process.env), process.stdout.isTTY ? { FORCE_COLOR: process.env.FORCE_COLOR || '1' } : {}),
27
+ stdio: 'pipe'
28
+ });
29
+ let data = '';
30
+ try {
31
+ for (var _c = tslib_1.__asyncValues(this.cp.stdout), _d; _d = await _c.next(), !_d.done;) {
32
+ const chunk = _d.value;
33
+ data += chunk;
34
+ }
35
+ }
36
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
37
+ finally {
38
+ try {
39
+ if (_d && !_d.done && (_a = _c.return)) await _a.call(_c);
40
+ }
41
+ finally { if (e_1) throw e_1.error; }
42
+ }
43
+ let error = '';
44
+ try {
45
+ for (var _e = tslib_1.__asyncValues(this.cp.stderr), _f; _f = await _e.next(), !_f.done;) {
46
+ const chunk = _f.value;
47
+ error += chunk;
48
+ }
49
+ }
50
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
51
+ finally {
52
+ try {
53
+ if (_f && !_f.done && (_b = _e.return)) await _b.call(_e);
54
+ }
55
+ finally { if (e_2) throw e_2.error; }
56
+ }
57
+ const exitCode = await new Promise((resolve, _reject) => {
58
+ this.cp.on('close', resolve);
59
+ });
60
+ if (exitCode) {
61
+ throw new Error(`subprocess error exit ${exitCode}, ${error}`);
62
+ }
63
+ return { data, error };
64
+ }
65
+ catch (err) {
66
+ throw new Error(err.message);
67
+ }
68
+ }
69
+ async checkPackageCanPublish(pkg, allPackages, version) {
70
+ this.log('');
71
+ cli_ux_1.default.action.start(`${pkg.name}@${pkg.version}`, undefined, { stdout: true });
72
+ let matchedPackage = allPackages.value.find(azurePackage => azurePackage.name === pkg.name);
73
+ if (pkg.version !== version) {
74
+ this.warn(`${pkg.name}@${pkg.version} doesn't match desired publish version!`);
75
+ cli_ux_1.default.action.stop(chalk_1.default.red(`version doesn't match version ${version}`));
76
+ throw new Error(`Version in package.json doesn't match desired published version`);
77
+ }
78
+ if (!matchedPackage) {
79
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('new package')}`);
80
+ cli_ux_1.default.action.start(`publish new package ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
81
+ await this.publishPackage(pkg);
82
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
83
+ return true;
84
+ }
85
+ let matchVersion = matchedPackage.versions.find(azurePackageVersion => azurePackageVersion.version === pkg.version);
86
+ if (!matchVersion) {
87
+ cli_ux_1.default.action.stop(`${chalk_1.default.yellow('version missing')}`);
88
+ cli_ux_1.default.action.start(`publish new version ${pkg.name}@${pkg.version} from ${pkg.jsonPath}`, undefined, { stdout: true });
89
+ await this.publishPackage(pkg);
90
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
91
+ return true;
92
+ }
93
+ this.warn(`${pkg.name}@${pkg.version} already exists`);
94
+ cli_ux_1.default.action.stop(`${chalk_1.default.blue('skipping')}`);
95
+ return false;
96
+ }
97
+ async publishPackages(packages, allPackages, version) {
98
+ let errorCount = 0;
99
+ this.log(`publishing ${packages.length} packages:`);
100
+ this.log(packages.map(pkg => pkg.name).toString());
101
+ for (const pkg of packages) {
102
+ try {
103
+ await this.checkPackageCanPublish(pkg, allPackages, version);
104
+ }
105
+ catch (_a) {
106
+ errorCount++;
107
+ continue;
108
+ }
109
+ }
110
+ if (errorCount > 0) {
111
+ throw new Error(`${errorCount} with Errors!`);
112
+ }
113
+ }
114
+ async run() {
115
+ try {
116
+ const { flags } = this.parse(NpmPublish);
117
+ let npmContext = new npm_1.default();
118
+ cli_ux_1.default.action.start('Parsing packages to check', undefined, { stdout: true });
119
+ const packages = await npmContext.packageList(flags.package, flags.exclude, this);
120
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
121
+ cli_ux_1.default.action.start('Getting list of published packages', undefined, { stdout: true });
122
+ const allPackages = JSON.parse(await npmContext.getAllNpmPackages(flags.pat));
123
+ cli_ux_1.default.action.stop(`${chalk_1.default.green('done')}`);
124
+ await this.publishPackages(packages, allPackages, flags.version);
125
+ cli_ux_1.default.action.stop('success');
126
+ }
127
+ catch (err) {
128
+ cli_ux_1.default.action.stop('error');
129
+ this.error(`${err.message}`);
130
+ }
131
+ }
132
+ }
133
+ exports.default = NpmPublish;
134
+ NpmPublish.description = 'Publish npm packages';
135
+ NpmPublish.usage = 'npm:publish [options]';
136
+ NpmPublish.examples = [
137
+ '$ ops npm:publish -v 15.0.0',
138
+ '$ ops npm:publish -v 15.0.0',
139
+ '$ ops npm:publish -p @adinsure-tooling/* -v 15.0.0',
140
+ '$ ops npm:publish -p @adinsure-tooling/* -x @adisure-tooling/studio-services -v 6.0.0'
141
+ ];
142
+ NpmPublish.flags = {
143
+ package: command_1.flags.string({
144
+ char: 'p',
145
+ description: 'package name filter you want to check',
146
+ multiple: true
147
+ }),
148
+ exclude: command_1.flags.string({
149
+ char: 'x',
150
+ description: 'exclude packages from filter',
151
+ multiple: true
152
+ }),
153
+ version: command_1.flags.string({
154
+ char: 'v',
155
+ description: 'version we want to check if published',
156
+ required: true
157
+ }),
158
+ pat: command_1.flags.string({
159
+ description: 'PAT token or AZURE_DEVOPS_EXT_PAT environment variable',
160
+ env: 'AZURE_DEVOPS_EXT_PAT'
161
+ }),
162
+ };
@@ -0,0 +1,29 @@
1
+ import { flags } from '@oclif/command';
2
+ import CommandBase from '../command.base';
3
+ interface Transformation {
4
+ name: string;
5
+ srcPath: string;
6
+ transform(): void;
7
+ }
8
+ interface DotfileLine {
9
+ prefix: string;
10
+ source: string;
11
+ transformData: string;
12
+ }
13
+ export default class PrepareContent extends CommandBase {
14
+ static readonly dotfile = ".opsprepare";
15
+ static description: string;
16
+ static usage: string;
17
+ static examples: string[];
18
+ static flags: {
19
+ destination: flags.IOptionFlag<string>;
20
+ source: flags.IOptionFlag<string>;
21
+ };
22
+ parseDotfileLine(line: string, sourceDirectory: string): Promise<DotfileLine>;
23
+ readDotfile(sourceDirectory: string): Promise<DotfileLine[]>;
24
+ getTransformation(lineData: DotfileLine, baseSourcedir: string, baseDestinationDir: string): Promise<Transformation>;
25
+ prepareTransformations(linesData: DotfileLine[], baseSourceDir: string, baseDestinationDir: string): Promise<Transformation[]>;
26
+ runTransformations(transformations: Transformation[]): Promise<void>;
27
+ run(): Promise<void>;
28
+ }
29
+ export {};