@adinsure-ops/ops-cli 4.8.2 → 5.0.0-rc3

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 (88) hide show
  1. package/CHANGELOGS.md +12 -0
  2. package/README.md +0 -211
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +6 -0
  5. package/bin/run.cmd +1 -1
  6. package/bin/run.js +8 -0
  7. package/lib/command.base.d.ts +9 -5
  8. package/lib/command.base.jira.d.ts +7 -8
  9. package/lib/command.base.jira.js +26 -24
  10. package/lib/command.base.js +69 -57
  11. package/lib/commands/docker/update-image-version.d.ts +6 -9
  12. package/lib/commands/docker/update-image-version.js +35 -34
  13. package/lib/commands/doctor.d.ts +15 -5
  14. package/lib/commands/doctor.js +219 -186
  15. package/lib/commands/download/client.d.ts +10 -7
  16. package/lib/commands/download/client.js +60 -52
  17. package/lib/commands/download/identity-server.d.ts +9 -7
  18. package/lib/commands/download/identity-server.js +59 -53
  19. package/lib/commands/download/jmeter.d.ts +5 -5
  20. package/lib/commands/download/jmeter.js +54 -49
  21. package/lib/commands/download/keycloak-scim.d.ts +6 -6
  22. package/lib/commands/download/keycloak-scim.js +56 -51
  23. package/lib/commands/download/platform.d.ts +9 -7
  24. package/lib/commands/download/platform.js +59 -53
  25. package/lib/commands/download/scheduler.d.ts +9 -7
  26. package/lib/commands/download/scheduler.js +59 -53
  27. package/lib/commands/download/server.d.ts +9 -7
  28. package/lib/commands/download/server.js +59 -53
  29. package/lib/commands/download/signalr.d.ts +9 -7
  30. package/lib/commands/download/signalr.js +59 -53
  31. package/lib/commands/download/studio.d.ts +11 -9
  32. package/lib/commands/download/studio.js +92 -82
  33. package/lib/commands/gitlab/get-tag-pipeline.d.ts +11 -14
  34. package/lib/commands/gitlab/get-tag-pipeline.js +95 -92
  35. package/lib/commands/gitlab/next-nightly-tag.d.ts +10 -12
  36. package/lib/commands/gitlab/next-nightly-tag.js +96 -98
  37. package/lib/commands/jira/issue.d.ts +6 -8
  38. package/lib/commands/jira/issue.js +25 -23
  39. package/lib/commands/jira/labels.d.ts +9 -12
  40. package/lib/commands/jira/labels.js +52 -51
  41. package/lib/commands/log/add.d.ts +6 -8
  42. package/lib/commands/log/add.js +92 -87
  43. package/lib/commands/log/generate.d.ts +9 -10
  44. package/lib/commands/log/generate.js +112 -107
  45. package/lib/commands/log/validate.d.ts +2 -2
  46. package/lib/commands/log/validate.js +47 -43
  47. package/lib/commands/login.d.ts +9 -10
  48. package/lib/commands/login.js +101 -97
  49. package/lib/commands/npm/check-publish.d.ts +7 -8
  50. package/lib/commands/npm/check-publish.js +59 -54
  51. package/lib/commands/npm/dependency-update.d.ts +14 -12
  52. package/lib/commands/npm/dependency-update.js +94 -86
  53. package/lib/commands/npm/publish.d.ts +8 -9
  54. package/lib/commands/npm/publish.js +154 -140
  55. package/lib/commands/nuget/dependency-update.d.ts +15 -10
  56. package/lib/commands/nuget/dependency-update.js +60 -49
  57. package/lib/commands/sql.d.ts +24 -20
  58. package/lib/commands/sql.js +246 -225
  59. package/lib/commands/translate.d.ts +15 -16
  60. package/lib/commands/translate.js +109 -104
  61. package/lib/commands/version.d.ts +29 -19
  62. package/lib/commands/version.js +215 -190
  63. package/lib/config.js +3 -6
  64. package/lib/hooks/init/version-override.d.ts +2 -2
  65. package/lib/hooks/init/version-override.js +15 -13
  66. package/lib/index.d.ts +1 -1
  67. package/lib/index.js +1 -4
  68. package/lib/lib/command.d.ts +2 -0
  69. package/lib/lib/command.js +65 -58
  70. package/lib/lib/gitlab.d.ts +8 -2
  71. package/lib/lib/gitlab.js +94 -79
  72. package/lib/lib/npm.d.ts +7 -3
  73. package/lib/lib/npm.js +72 -60
  74. package/lib/lib/npmrc.d.ts +5 -0
  75. package/lib/lib/npmrc.js +20 -13
  76. package/lib/lib/nuget.d.ts +2 -0
  77. package/lib/lib/nuget.js +20 -17
  78. package/lib/security/cache.js +31 -27
  79. package/lib/security/context.d.ts +2 -1
  80. package/lib/security/context.js +106 -103
  81. package/lib/types/changelog.types.js +1 -2
  82. package/lib/types/npm.types.d.ts +5 -5
  83. package/lib/types/npm.types.js +1 -2
  84. package/oclif.manifest.json +1212 -1
  85. package/package.json +52 -47
  86. package/bin/run +0 -5
  87. package/lib/commands/prepare-content.d.ts +0 -29
  88. package/lib/commands/prepare-content.js +0 -386
package/CHANGELOGS.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelogs
2
2
 
3
+ ## 5.0.0-rc1
4
+
5
+ - bugfixes
6
+ - security patching: the project was migrated to a new oclif framework from the old one
7
+ - performace tuning
8
+ - removal of the prepare-content command
9
+
10
+ ## 4.8.3: 2023-08-22
11
+
12
+ - bugfixes; sql command was fixed so that even when Extend was not used it required its parameters
13
+ - security patches in library dependencies
14
+
3
15
  ## 4.8.2: 2023-07-28
4
16
 
5
17
  - sql command can now generate a template for mssql and oracle, for extending an sql table with a column
package/README.md CHANGED
@@ -47,7 +47,6 @@ You can run and debug commands directly from terminal by running `ops [command]`
47
47
  - [`ops npm:publish`](##ops-npm:publish)
48
48
  - [`ops npm:dependency-update`](##ops-npm:dependency-update)
49
49
  - [`ops nuget:dependency-update`](##ops-nuget:dependency-update)
50
- - [`ops prepare-content`](##ops-prepare-content)
51
50
  - [`ops sql <type> <module> [flags]`](##ops-sql-<type>-<module>-[flags])
52
51
  - [`ops translate`](##ops-translate)
53
52
  - [`ops version <type> [flags]`](##ops-version-<type>[flags])
@@ -487,216 +486,6 @@ EXAMPLE
487
486
  $ ops nuget:dependency-update 3.4.3 --filter Adacta.AdInsure --exclude Scheduler
488
487
  ```
489
488
 
490
- ## `ops prepare-content -d <destination> -s [source]`
491
-
492
- creates a directory/file structure from `/source` to `/destination</source>` as defined in the `.opsprepare` file. Actual
493
- destination path for each file will be specified destination path with appended relative path from working directory where command is executed to specified source directory or current directory (if source is not specified). Be careful about using
494
- `..` notation in target and source paths as it may lead to unpredictable results due to relative path resolving.
495
-
496
- > Introduced in version 3.1.0.
497
-
498
- ```txt
499
- USAGE
500
- $ ops prepare-content -d <destination> -s [source]
501
-
502
-
503
- OPTIONS
504
- -d, --destination=destination path to target directory
505
- -s, --source=source optional path to source directory containing .opsprepare file, (default: current directory)
506
-
507
- EXAMPLES
508
- $ ops prepare-content -d ./target_directory/
509
- copies everything defined in .opsprepare
510
- from current directory
511
- to ./target_directory
512
-
513
- $ ops prepare-content -d ./target_directory/ -s ./source_directory
514
- copies everything defined in ./source_directory/.opsprepare
515
- from ./source_directory/
516
- to ./target_directory/source_directory
517
-
518
- $ ops prepare-content -d C:\git\target_directory
519
- copies everything defined in .opsprepare
520
- from current directory
521
- to C:\git\target_directory
522
-
523
- $ ops prepare-content -d C:\git\target_directory -s C:\git\subfolder\subfolder
524
- when executed in c:\git it copies everything defined in C:\git\subfolder\subfolder\.opsprepare
525
- from C:\git\subfolder\subfolder
526
- to C:\git\target_directory\subfolder\subfolder
527
- ```
528
-
529
- ### .opsprepare dotfile
530
-
531
- The prepare-content command uses `.opsprepare` dotfile as instruction set for content preparation.
532
- The syntax resembles that of `.gitignore` but differs in how it functions and doesn't support advanced
533
- pattern matching.
534
-
535
- Following operations/transformations are currently supported:
536
-
537
- - Copy: copies the file/directory from source path to destination path with same name
538
- - Transform: transform source file to destination file with same name
539
- - Removal: remove file/directory (based on source path) from destination path
540
-
541
- Before diving into the actual syntax and supported tokens let's look at an example
542
- of how using `ops prepare-content` creates a target directory structure with files
543
- based on the specified `.opsprepare` file residing in source directory.
544
-
545
- This is the example source directory structure:
546
-
547
- ```ascii
548
- src_data
549
- ├── .opsprepare
550
- ├── README.tpl
551
- ├── bin
552
- │   ├── ops.sh
553
- │   └── run
554
- │   └── ops
555
- ├── dist
556
- │   └── server
557
- │   └── main.cs
558
- ├── src
559
- │   ├── commands
560
- │   │   ├── prepare.ts
561
- │   │   └── version.ts
562
- │   ├── config.ts
563
- │   └── main.ts
564
- └── transform
565
- └── render-tpl.js
566
- ```
567
-
568
- Contents of `.opsprepare` file in the `src_data` directory:
569
-
570
- ```txt
571
- # Comment
572
- src
573
- dist/server
574
- !src/commands
575
- !src/config.ts
576
- src/config.ts {cp:/src/configuration.ts}
577
- # Another comment
578
- !bin/run
579
- README.md {js:/transform/render-tpl.js:render}
580
- README.tpl {cp:/README.tpl.src}
581
- ```
582
-
583
- Running `ops -s src_data -d dst_data` with `src_data/.opsprepare` containing above content
584
- results in:
585
-
586
- ```ascii
587
- dst_data
588
- └── src_data
589
- ├── README.md
590
- ├── README.tpl.src
591
- ├── dist
592
- │   └── server
593
- │   └── main.cs
594
- └── src
595
- ├── main.ts
596
- └── src
597
- └── configuration.ts
598
- ```
599
-
600
- What actually happened:
601
-
602
- 1. First note that all data was copied into `dst_data/src_data` because `.opsprepare` files relative
603
- location to `ops` execution directiory is `src_data`.
604
- 2. `src` directory was copied recursively to destination
605
- 3. `dist/server` directory was copied recursively including its full path path relative to `src_data`
606
- 4. `src/config.ts` file was transformed (copied) to `src/configuration.ts` in the destination
607
- 5. `README.md` file was created at the destination as a result of JavaScript based transformation
608
- 6. `README.tpl` file was transformed (copied) to `README.tpl.src` in the destination
609
- 7. `src/commands` directory was removed from destination
610
- 8. `src/config.ts` file was removed from destination
611
- 9. `bin/run` directory was removed from destination
612
-
613
- Note that copying and explicit transformations are performed before any removal operations.
614
-
615
- #### Comments
616
-
617
- Any line prefixed by `#` is considered a comment and will not result in any file/directory operation.
618
-
619
- #### Copy operations
620
-
621
- Any file/directory not prefixed by `!` or `#` having explicit transformation defined in `{...}` after
622
- its name will be copied to the destination with it's full path relative to `ops` execution directory
623
- to the target directory.
624
-
625
- #### Transformation operations
626
-
627
- Transformation operations are always specified using curly braces following the source file name. Base
628
- syntax looks like this:
629
-
630
- ```txt
631
- {<transformation type>:<transformation parameters>}
632
- ```
633
-
634
- Two types of transformation operations are supported:
635
-
636
- - cp: copy transformation which supports renaming of the source file at the destination
637
- - js: JavasSript based transformation which results in the file containing string returned by the
638
- transformation function contained in transformation module.
639
-
640
- **cp - copy transformation syntax**
641
-
642
- ```txt
643
- {cp:<destination path>}
644
-
645
- Examples:
646
- {cp:/dst/newfilename}
647
- {cp:dst/newfilenames}
648
- ```
649
-
650
- Copy transformation is supported for both files and directories. Source file or directory will be
651
- copied to the destination path with its new name. The destination will always be relative to the
652
- destination path of entire `prepare-content` operation therefore paths in the transformation block
653
- can start with or without the `/` character but using makes the syntax more readable.
654
-
655
- **js - JavaScript transformation syntax**
656
-
657
- ```txt
658
- {js:<transformation_module_path>:<transformation_function_name>}
659
-
660
- Example:
661
- {js:/transformations/templateRenderer.js:renderEjsTemplate}
662
- ```
663
-
664
- JavaScript transformation is supported only for files, not directories.
665
-
666
- Transformation module path should be relative to `.opsprepare` file but can start with `/` character
667
- for better readability. It can export multiple functions though only one can be used in single
668
- transformation specification.
669
-
670
- Transformation function that is defined in the transformation module will be called with a single
671
- parameter - absolute path of the source file.
672
-
673
- Transformation function MUST return a string. This string will become the content of the file on
674
- destination.
675
-
676
- Destination file will be created with the same name as source file and content returned by the
677
- transformation function. The existence of actual source file will not be validated by the
678
- `prepare-content` operation (warning is shown if it doesn't exist), such validation is responsibility
679
- of the transformation function if required.
680
-
681
- Example transformation module `transform.js` with exported function called transform:
682
-
683
- ```js
684
- module.exports = {
685
- render: (path) => {
686
- /*
687
- Some transformation happens in here and it's result which is
688
- a string is assigned to result variable which is returned.
689
- */
690
- return result;
691
- }
692
- }
693
- ```
694
-
695
- #### Removal operations
696
-
697
- Any file/directory prefixed by `!` will be removed from the destination based on it's full path
698
- relative from `ops` execution directory to source file/directory path.
699
-
700
489
  ## `ops version <type>`
701
490
 
702
491
  creates everything necessary for the new release
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --trace-warnings "%~dp0\dev.js" %*
package/bin/dev.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ts-node
2
+ // eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
3
+ (async () => {
4
+ const oclif = await import('@oclif/core');
5
+ await oclif.execute({ type: 'esm', development: true, dir: import.meta.url });
6
+ })();
package/bin/run.cmd CHANGED
@@ -1,3 +1,3 @@
1
1
  @echo off
2
2
 
3
- node "%~dp0\run" %*
3
+ ts-node-esm "%~dp0\run.js" %*
package/bin/run.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ // eslint-disable-next-line node/shebang
3
+ import oclif from '@oclif/core';
4
+
5
+ /* eslint-disable unicorn/prefer-top-level-await */
6
+ oclif.run(process.argv.slice(2), import.meta.url)
7
+ .then(oclif.flush)
8
+ .catch(oclif.Errors.handle);
@@ -1,17 +1,21 @@
1
- import { Command } from '@oclif/command';
2
- import { IConfig } from '@oclif/config';
3
- import SecurityContext from './security/context';
4
- export default abstract class CommandBase extends Command {
1
+ import { Command, Config } from '@oclif/core';
2
+ import SecurityContext from './security/context.js';
3
+ export default abstract class CommandBase<T extends typeof Command> extends Command {
5
4
  protected readonly security: SecurityContext;
6
- constructor(argv: string[], config: IConfig);
5
+ constructor(argv: string[], config: Config);
7
6
  getGitRoot(startDir?: string): Promise<string>;
8
7
  getVersion(versionFile?: string, ...filesToCheck: string[]): Promise<string>;
9
8
  /**
10
9
  * Resolve path to Changelog folder from current execution directory
10
+ * @returns {string} the resolved path to changelogs
11
11
  */
12
12
  getChangelogsRoot(): Promise<string>;
13
13
  /**
14
14
  * Get all files inside directory and normalize it against {baseRelativePath}.
15
+ * @param {string} dir The name or path of the current directory
16
+ * @param {string} baseRelativePath The relatice path format from the `dir`
17
+ * @param {RegExp} filter Regular expressions filter for the file path
18
+ * @returns {string[]} An array of files inside the directory with the specified filter
15
19
  */
16
20
  getFilesRecursive(dir: string, baseRelativePath: string, filter: RegExp): Promise<string[]>;
17
21
  }
@@ -1,11 +1,10 @@
1
- import { flags } from '@oclif/command';
2
- import JiraApi = require('jira-client');
3
- import CommandBase from './command.base';
4
- export default abstract class CommandBaseJira extends CommandBase {
1
+ import JiraApi from 'jira-client';
2
+ import CommandBase from './command.base.js';
3
+ export default abstract class CommandBaseJira extends CommandBase<typeof CommandBaseJira> {
5
4
  static flags: {
6
- username: flags.IOptionFlag<string>;
7
- password: flags.IOptionFlag<string>;
8
- hostname: flags.IOptionFlag<string>;
5
+ username: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
6
+ password: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
+ hostname: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
8
  };
10
- jiraInit(url: string, username: string, password: string): Promise<JiraApi>;
9
+ jiraInit(urlString: string, username: string, password: string): Promise<JiraApi>;
11
10
  }
@@ -1,37 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const JiraApi = require("jira-client");
5
- const command_base_1 = require("./command.base");
6
- class CommandBaseJira extends command_base_1.default {
7
- async jiraInit(url, username, password) {
8
- const jiraUrl = new URL(url);
9
- const jira = new JiraApi({
10
- protocol: jiraUrl.protocol,
11
- host: jiraUrl.hostname,
12
- username,
13
- password,
14
- apiVersion: '2',
15
- strictSSL: true
1
+ import { __awaiter } from "tslib";
2
+ import { Flags } from '@oclif/core';
3
+ import JiraApi from 'jira-client';
4
+ import url from 'url';
5
+ import CommandBase from './command.base.js';
6
+ class CommandBaseJira extends CommandBase {
7
+ jiraInit(urlString, username, password) {
8
+ return __awaiter(this, void 0, void 0, function* () {
9
+ const jiraUrl = new url.URL(urlString);
10
+ const jira = new JiraApi({
11
+ protocol: jiraUrl.protocol,
12
+ host: jiraUrl.hostname,
13
+ username,
14
+ password,
15
+ apiVersion: '2',
16
+ strictSSL: true,
17
+ });
18
+ return jira;
16
19
  });
17
- return jira;
18
20
  }
19
21
  }
20
- exports.default = CommandBaseJira;
21
22
  CommandBaseJira.flags = {
22
- username: command_1.flags.string({
23
+ username: Flags.string({
23
24
  description: 'jira username',
24
25
  env: 'JIRA_USERNAME',
25
- required: true
26
+ required: true,
26
27
  }),
27
- password: command_1.flags.string({
28
+ password: Flags.string({
28
29
  description: 'jira password',
29
30
  env: 'JIRA_PASSWORD',
30
- required: true
31
+ required: true,
31
32
  }),
32
- hostname: command_1.flags.string({
33
+ hostname: Flags.string({
33
34
  description: 'jira hostname',
34
35
  default: 'https://jira.adacta-fintech.com',
35
- env: 'JIRA_HOSTNAME'
36
- })
36
+ env: 'JIRA_HOSTNAME',
37
+ }),
37
38
  };
39
+ export default CommandBaseJira;
@@ -1,73 +1,85 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const fs = require("fs-extra");
5
- const path = require("path");
6
- const context_1 = require("./security/context");
7
- class CommandBase extends command_1.Command {
1
+ import { __awaiter } from "tslib";
2
+ import { Command } from '@oclif/core';
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import SecurityContext from './security/context.js';
6
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
7
+ export default class CommandBase extends Command {
8
8
  constructor(argv, config) {
9
9
  super(argv, config);
10
- this.security = new context_1.default(this.config.configDir);
10
+ this.security = new SecurityContext(this.config.configDir);
11
11
  }
12
- async getGitRoot(startDir) {
13
- let currentPath = path.resolve(startDir || process.cwd());
14
- // tslint:disable-next-line: no-constant-condition
15
- while (true) {
16
- // We've reached the root and didn't find .git
17
- if (currentPath === path.parse(currentPath).root) {
18
- throw new Error('Not a git repository (or any of the parent directories)');
12
+ getGitRoot(startDir) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ let currentPath = path.resolve(startDir !== null && startDir !== void 0 ? startDir : process.cwd());
15
+ /* eslint-disable-next-line no-constant-condition */
16
+ while (true) {
17
+ // We've reached the root and didn't find .git
18
+ if (currentPath === path.parse(currentPath).root) {
19
+ throw new Error('Not a git repository (or any of the parent directories)');
20
+ }
21
+ if (yield fs.pathExists(path.resolve(currentPath, '.git'))) {
22
+ // toLowerCase because of different behaviour when executing tests with yarn or with Test Explorer in VS Code
23
+ return currentPath.toLowerCase();
24
+ }
25
+ currentPath = path.dirname(currentPath);
19
26
  }
20
- if (await fs.pathExists(path.resolve(currentPath, '.git'))) {
21
- // toLowerCase because of different behaviour when executing tests with yarn or with Test Explorer in VS Code
22
- return currentPath.toLowerCase();
23
- }
24
- currentPath = path.dirname(currentPath);
25
- }
27
+ });
26
28
  }
27
- async getVersion(versionFile = 'VERSION', ...filesToCheck) {
28
- filesToCheck.unshift(versionFile);
29
- const gitRoot = await this.getGitRoot();
30
- for (const file of filesToCheck) {
31
- const versionPath = path.resolve(gitRoot, file);
32
- if (await fs.pathExists(versionPath)) {
33
- return fs.readFileSync(versionPath, 'utf-8').trim();
29
+ getVersion(versionFile = 'VERSION', ...filesToCheck) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ filesToCheck.unshift(versionFile);
32
+ const gitRoot = yield this.getGitRoot();
33
+ for (const file of filesToCheck) {
34
+ const versionPath = path.resolve(gitRoot, file);
35
+ if (yield fs.pathExists(versionPath)) {
36
+ return fs.readFileSync(versionPath, 'utf8').trim();
37
+ }
34
38
  }
35
- }
36
- return this.error(`${filesToCheck} file was not found`, { exit: 2 });
39
+ return this.error(`${filesToCheck} file was not found`, { exit: 2 });
40
+ });
37
41
  }
38
42
  /**
39
43
  * Resolve path to Changelog folder from current execution directory
44
+ * @returns {string} the resolved path to changelogs
40
45
  */
41
- async getChangelogsRoot() {
42
- let currentPath = path.resolve(process.cwd());
43
- if (!await fs.pathExists(currentPath)) {
44
- this.log(`Directory '${currentPath}' doesn't exist ... nothing to do here.`);
45
- this.exit(0);
46
- }
47
- return path.resolve(currentPath, 'changelogs', 'unreleased');
46
+ getChangelogsRoot() {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const currentPath = path.resolve(process.cwd());
49
+ if (!(yield fs.pathExists(currentPath))) {
50
+ this.log(`Directory '${currentPath}' doesn't exist ... nothing to do here.`);
51
+ this.exit(0);
52
+ }
53
+ return path.resolve(currentPath, 'changelogs', 'unreleased');
54
+ });
48
55
  }
49
56
  /**
50
57
  * Get all files inside directory and normalize it against {baseRelativePath}.
58
+ * @param {string} dir The name or path of the current directory
59
+ * @param {string} baseRelativePath The relatice path format from the `dir`
60
+ * @param {RegExp} filter Regular expressions filter for the file path
61
+ * @returns {string[]} An array of files inside the directory with the specified filter
51
62
  */
52
- async getFilesRecursive(dir, baseRelativePath, filter) {
53
- if (!await fs.pathExists(dir)) {
54
- this.warn(`Directory '${dir}' doesn't exist ... nothing to do here.`);
55
- return [];
56
- }
57
- let relativePath = path.relative(baseRelativePath, dir);
58
- relativePath = relativePath === '' ? '.' : relativePath;
59
- const entries = await fs.readdir(dir);
60
- // Get files within the current directory and add a relative path to the file objects
61
- const files = entries
62
- .filter(file => !fs.statSync(path.resolve(dir, file)).isDirectory())
63
- .filter(file => filter.test(path.resolve(dir, file)))
64
- .map(file => `${relativePath}/${file}`);
65
- // Get folders within the current directory
66
- const folders = entries.filter(filetype => fs.statSync(path.resolve(dir, filetype)).isDirectory());
67
- for (const folder of folders)
68
- // Recursivly call this function and get relative paths of files inside directory
69
- files.push(...await this.getFilesRecursive(path.join(dir, folder), baseRelativePath, filter));
70
- return files;
63
+ getFilesRecursive(dir, baseRelativePath, filter) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ if (!(yield fs.pathExists(dir))) {
66
+ this.warn(`Directory '${dir}' doesn't exist ... nothing to do here.`);
67
+ return [];
68
+ }
69
+ let relativePath = path.relative(baseRelativePath, dir);
70
+ relativePath = relativePath === '' ? '.' : relativePath;
71
+ const entries = yield fs.readdir(dir);
72
+ // Get files within the current directory and add a relative path to the file objects
73
+ const files = entries
74
+ .filter(file => !fs.statSync(path.resolve(dir, file)).isDirectory())
75
+ .filter(file => filter.test(path.resolve(dir, file)))
76
+ .map(file => `${relativePath}/${file}`);
77
+ // Get folders within the current directory
78
+ const folders = entries.filter(filetype => fs.statSync(path.resolve(dir, filetype)).isDirectory());
79
+ for (const folder of folders)
80
+ // Recursivly call this function and get relative paths of files inside directory
81
+ files.push(...yield this.getFilesRecursive(path.join(dir, folder), baseRelativePath, filter));
82
+ return files;
83
+ });
71
84
  }
72
85
  }
73
- exports.default = CommandBase;
@@ -1,17 +1,14 @@
1
- import { flags } from '@oclif/command';
2
- import CommandBase from '../../command.base';
3
- export default class DockerUpdateImageVersion extends CommandBase {
1
+ import CommandBase from '../../command.base.js';
2
+ export default class DockerUpdateImageVersion extends CommandBase<typeof DockerUpdateImageVersion> {
4
3
  static description: string;
5
4
  static usage: string;
6
5
  static examples: string[];
7
6
  static args: {
8
- name: string;
9
- description: string;
10
- required: boolean;
11
- }[];
7
+ version: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
8
+ };
12
9
  static flags: {
13
- services: flags.IOptionFlag<string[]>;
14
- 'file-path': flags.IOptionFlag<string>;
10
+ services: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[], import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ 'file-path': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
12
  };
16
13
  run(): Promise<void>;
17
14
  }
@@ -1,47 +1,48 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
4
- const fs = require("fs-extra");
5
- const yaml_1 = require("yaml");
6
- const command_base_1 = require("../../command.base");
7
- class DockerUpdateImageVersion extends command_base_1.default {
8
- async run() {
9
- const { args, flags } = this.parse(DockerUpdateImageVersion);
10
- try {
11
- let parsedYaml = yaml_1.parse(fs.readFileSync(flags['file-path'], 'utf8'));
12
- for (let service of flags.services) {
13
- let image = parsedYaml.services[service].image.split(':');
14
- image[1] = args.version;
15
- parsedYaml.services[service].image = image.join(':');
1
+ import { __awaiter } from "tslib";
2
+ import { Args, Flags } from '@oclif/core';
3
+ import fs from 'fs-extra';
4
+ import { parse as yamlParse, stringify as yamlStringify } from 'yaml';
5
+ import CommandBase from '../../command.base.js';
6
+ class DockerUpdateImageVersion extends CommandBase {
7
+ run() {
8
+ return __awaiter(this, void 0, void 0, function* () {
9
+ const { args, flags } = yield this.parse(DockerUpdateImageVersion);
10
+ try {
11
+ const parsedYaml = yamlParse(fs.readFileSync(flags['file-path'], 'utf8'));
12
+ for (const service of flags.services) {
13
+ const image = parsedYaml.services[service].image.split(':');
14
+ image[1] = args.version;
15
+ parsedYaml.services[service].image = image.join(':');
16
+ }
17
+ fs.writeFileSync(flags['file-path'], yamlStringify(parsedYaml));
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
19
  }
17
- fs.writeFileSync(flags['file-path'], yaml_1.stringify(parsedYaml));
18
- }
19
- catch (err) {
20
- this.error(err.message);
21
- }
20
+ catch (error) {
21
+ this.error(error.message);
22
+ }
23
+ });
22
24
  }
23
25
  }
24
- exports.default = DockerUpdateImageVersion;
25
26
  DockerUpdateImageVersion.description = 'update docker image version docker compose file';
26
27
  DockerUpdateImageVersion.usage = 'docker:update-image-version <tag>';
27
28
  DockerUpdateImageVersion.examples = [
28
- `$ ops docker:update-image-version 17.0.0 --service server client`
29
- ];
30
- DockerUpdateImageVersion.args = [
31
- {
32
- name: 'version',
33
- description: 'version',
34
- required: true
35
- }
29
+ `$ ops docker:update-image-version 17.0.0 --service server client`,
36
30
  ];
31
+ DockerUpdateImageVersion.args = {
32
+ version: Args.string({
33
+ required: true,
34
+ description: 'Version',
35
+ }),
36
+ };
37
37
  DockerUpdateImageVersion.flags = {
38
- services: command_1.flags.string({
38
+ services: Flags.string({
39
39
  required: true,
40
40
  description: 'list of services to update',
41
- multiple: true
41
+ multiple: true,
42
42
  }),
43
- 'file-path': command_1.flags.string({
43
+ 'file-path': Flags.string({
44
44
  default: './docker-compose.yml',
45
- description: 'list of services to update'
46
- })
45
+ description: 'list of services to update',
46
+ }),
47
47
  };
48
+ export default DockerUpdateImageVersion;