@wocker/ws 1.0.31 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/lib/AppModule.js +1 -2
  2. package/lib/main.js +2 -2
  3. package/lib/makes/GithubClient.d.ts +3 -2
  4. package/lib/makes/GithubClient.js +27 -27
  5. package/lib/makes/index.d.ts +0 -3
  6. package/lib/makes/index.js +0 -3
  7. package/lib/modules/core/controllers/DebugController.d.ts +3 -4
  8. package/lib/modules/core/controllers/DebugController.js +5 -22
  9. package/lib/modules/core/controllers/ExperimentalController.d.ts +3 -3
  10. package/lib/modules/core/controllers/ExperimentalController.js +1 -1
  11. package/lib/modules/dns/index.js +3 -3
  12. package/lib/modules/keystore/controllers/KeystoreController.d.ts +3 -3
  13. package/lib/modules/keystore/controllers/KeystoreController.js +8 -8
  14. package/lib/modules/keystore/providers/FileKeystoreProvider.js +8 -8
  15. package/lib/modules/keystore/services/KeystoreService.d.ts +3 -3
  16. package/lib/modules/keystore/services/KeystoreService.js +4 -4
  17. package/lib/modules/package-manager/service/PackageManager.d.ts +3 -3
  18. package/lib/modules/package-manager/service/PackageManager.js +8 -8
  19. package/lib/modules/package-manager/service/RegistryService.js +5 -4
  20. package/lib/modules/plugin/controllers/PluginController.d.ts +3 -3
  21. package/lib/modules/plugin/controllers/PluginController.js +4 -4
  22. package/lib/modules/plugin/index.js +4 -5
  23. package/lib/modules/plugin/services/PluginService.d.ts +3 -3
  24. package/lib/modules/plugin/services/PluginService.js +11 -13
  25. package/lib/modules/preset/controllers/PresetController.d.ts +3 -3
  26. package/lib/modules/preset/controllers/PresetController.js +6 -6
  27. package/lib/modules/preset/controllers/PresetListener.d.ts +5 -3
  28. package/lib/modules/preset/controllers/PresetListener.js +21 -30
  29. package/lib/modules/preset/repositories/PresetRepository.d.ts +3 -3
  30. package/lib/modules/preset/repositories/PresetRepository.js +7 -7
  31. package/lib/modules/preset/services/PresetService.d.ts +4 -3
  32. package/lib/modules/preset/services/PresetService.js +33 -33
  33. package/lib/modules/project/controllers/MetadataController.d.ts +8 -0
  34. package/lib/modules/project/controllers/MetadataController.js +89 -0
  35. package/lib/modules/project/controllers/ProjectController.d.ts +6 -6
  36. package/lib/modules/project/controllers/ProjectController.js +63 -49
  37. package/lib/modules/project/controllers/SecretsController.js +2 -2
  38. package/lib/modules/project/index.d.ts +1 -2
  39. package/lib/modules/project/index.js +4 -6
  40. package/lib/modules/project/services/ProjectService.d.ts +5 -6
  41. package/lib/modules/project/services/ProjectService.js +38 -39
  42. package/lib/modules/proxy/controllers/CertController.js +6 -0
  43. package/lib/modules/proxy/controllers/HttpAuthController.d.ts +15 -0
  44. package/lib/modules/proxy/controllers/HttpAuthController.js +137 -0
  45. package/lib/modules/proxy/controllers/ProxyController.d.ts +3 -3
  46. package/lib/modules/proxy/controllers/ProxyController.js +11 -11
  47. package/lib/modules/proxy/index.js +4 -0
  48. package/lib/modules/proxy/services/CertService.d.ts +6 -5
  49. package/lib/modules/proxy/services/CertService.js +1 -2
  50. package/lib/modules/proxy/services/HttpAuthService.d.ts +23 -0
  51. package/lib/modules/proxy/services/HttpAuthService.js +137 -0
  52. package/lib/modules/proxy/services/ProxyService.d.ts +4 -3
  53. package/lib/modules/proxy/services/ProxyService.js +31 -19
  54. package/lib/utils/index.d.ts +0 -1
  55. package/lib/utils/index.js +0 -1
  56. package/package.json +5 -13
  57. package/plugins/proxy/Dockerfile +14 -4
  58. package/plugins/proxy/wocker-entrypoint.sh +11 -0
  59. package/lib/makes/Http.d.ts +0 -18
  60. package/lib/makes/Http.js +0 -82
  61. package/lib/makes/Version.d.ts +0 -22
  62. package/lib/makes/Version.js +0 -59
  63. package/lib/makes/VersionRange.d.ts +0 -6
  64. package/lib/makes/VersionRange.js +0 -18
  65. package/lib/makes/VersionRule.d.ts +0 -24
  66. package/lib/makes/VersionRule.js +0 -68
  67. package/lib/modules/project/repositories/ProjectRepository.d.ts +0 -10
  68. package/lib/modules/project/repositories/ProjectRepository.js +0 -71
  69. package/lib/utils/injectVariables.d.ts +0 -5
  70. package/lib/utils/injectVariables.js +0 -10
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HttpAuthService = void 0;
13
+ const core_1 = require("@wocker/core");
14
+ const docker_module_1 = require("@wocker/docker-module");
15
+ const ProxyService_1 = require("./ProxyService");
16
+ let HttpAuthService = class HttpAuthService {
17
+ constructor(processService, fs, dockerService, proxyService) {
18
+ this.processService = processService;
19
+ this.fs = fs;
20
+ this.dockerService = dockerService;
21
+ this.proxyService = proxyService;
22
+ }
23
+ async users(path) {
24
+ await this.dockerService.exec("wocker-proxy", {
25
+ tty: true,
26
+ user: "nginx",
27
+ cmd: ["cut", "-d:", "-f1", `/etc/${path}`]
28
+ });
29
+ }
30
+ async add(path, user, password, algorithm = "md5") {
31
+ const alMap = {
32
+ md5: "-m",
33
+ sha1: "-s",
34
+ sha256: "-2",
35
+ sha512: "-5",
36
+ bcrypt: "-B",
37
+ };
38
+ if (!(algorithm in alMap)) {
39
+ throw new Error(`Unsupported "${algorithm}" algorithm`);
40
+ }
41
+ if (!this.fs.exists(path)) {
42
+ this.fs.writeFile(path, "", {
43
+ mode: 0o640
44
+ });
45
+ }
46
+ await this.dockerService.exec("wocker-proxy", {
47
+ user: "nginx",
48
+ cmd: ["htpasswd", "-b", alMap[algorithm], `/etc/${path}`, user, password],
49
+ tty: true
50
+ });
51
+ }
52
+ async addForProject(project, user, password, algorithm = "md5") {
53
+ if (!this.fs.exists("nginx/htpasswd/projects")) {
54
+ this.fs.mkdir("nginx/htpasswd/projects", {
55
+ mode: 0o764
56
+ });
57
+ }
58
+ await this.add(`nginx/htpasswd/projects/${project.name}`, user, password, algorithm);
59
+ }
60
+ async addForGlobal(user, password, algorithm = "md5") {
61
+ return this.add(`nginx/htpasswd/_global`, user, password, algorithm);
62
+ }
63
+ async removeUser(path, user) {
64
+ await this.dockerService.exec("wocker-proxy", {
65
+ cmd: ["htpasswd", "-D", `/etc/${path}`, user],
66
+ user: "nginx",
67
+ tty: true
68
+ });
69
+ }
70
+ async usersForProject(project) {
71
+ if (!this.fs.exists("nginx/htpasswd/projects")) {
72
+ return;
73
+ }
74
+ await this.users(`nginx/htpasswd/projects/${project.name}`);
75
+ }
76
+ async removeForProject(project, user) {
77
+ if (!this.fs.exists("nginx/htpasswd/projects")) {
78
+ return;
79
+ }
80
+ await this.removeUser(`nginx/htpasswd/projects/${project.name}`, user);
81
+ }
82
+ async clearForProject(project) {
83
+ const filePath = `nginx/htpasswd/projects/${project.name}`;
84
+ if (this.fs.exists(filePath)) {
85
+ this.fs.writeFile(filePath, "", {
86
+ mode: 0o640
87
+ });
88
+ }
89
+ }
90
+ async enableForProject(project, domain) {
91
+ if (!this.fs.exists(`nginx/htpasswd/projects/${project.name}`)) {
92
+ throw new Error(`No htpasswd for ${project.name}`);
93
+ }
94
+ if (!domain) {
95
+ for (const d of project.domains) {
96
+ await this.enableForProject(project, d);
97
+ }
98
+ return;
99
+ }
100
+ if (!project.domains.includes(domain)) {
101
+ throw new Error("Domain not related to project");
102
+ }
103
+ const filePath = `nginx/htpasswd/${domain}`;
104
+ if (this.fs.exists(filePath)) {
105
+ return;
106
+ }
107
+ this.fs.symlink(`nginx/htpasswd/projects/${project.name}`, filePath, "file");
108
+ }
109
+ async disableForProject(project, domain) {
110
+ if (!domain) {
111
+ for (const d of project.domains) {
112
+ await this.disableForProject(project, d);
113
+ }
114
+ return;
115
+ }
116
+ const filePath = `nginx/htpasswd/${domain}`;
117
+ if (!this.fs.exists(filePath)) {
118
+ return;
119
+ }
120
+ const stat = this.fs.lstat(filePath);
121
+ if (!stat.isSymbolicLink()) {
122
+ return;
123
+ }
124
+ if (`projects/${project.name}` !== this.fs.readlink(filePath)) {
125
+ return;
126
+ }
127
+ this.fs.unlink(filePath);
128
+ }
129
+ };
130
+ exports.HttpAuthService = HttpAuthService;
131
+ exports.HttpAuthService = HttpAuthService = __decorate([
132
+ (0, core_1.Injectable)(),
133
+ __metadata("design:paramtypes", [core_1.ProcessService,
134
+ core_1.AppFileSystemService,
135
+ docker_module_1.DockerService,
136
+ ProxyService_1.ProxyService])
137
+ ], HttpAuthService);
@@ -1,14 +1,15 @@
1
- import { Project, AppConfigService, AppFileSystemService, ProxyService as CoreProxyService } from "@wocker/core";
1
+ import { Project, AppService, AppFileSystemService, ProcessService, ProxyService as CoreProxyService } from "@wocker/core";
2
2
  import { DockerService } from "@wocker/docker-module";
3
3
  export declare class ProxyService extends CoreProxyService {
4
- protected readonly appConfigService: AppConfigService;
4
+ protected readonly appService: AppService;
5
+ protected readonly processService: ProcessService;
5
6
  protected readonly fs: AppFileSystemService;
6
7
  protected readonly dockerService: DockerService;
7
8
  protected containerName: string;
8
9
  protected oldContainerNames: string[];
9
10
  protected imageName: string;
10
11
  protected oldImages: string[];
11
- constructor(appConfigService: AppConfigService, fs: AppFileSystemService, dockerService: DockerService);
12
+ constructor(appService: AppService, processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService);
12
13
  init(project: Project): Promise<void>;
13
14
  start(restart?: boolean, rebuild?: boolean): Promise<void>;
14
15
  stop(): Promise<void>;
@@ -45,24 +45,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.ProxyService = void 0;
46
46
  const core_1 = require("@wocker/core");
47
47
  const docker_module_1 = require("@wocker/docker-module");
48
- const utils_1 = require("@wocker/utils");
48
+ const prompts_1 = require("@wocker/prompts");
49
49
  const Path = __importStar(require("path"));
50
50
  const env_1 = require("../../../env");
51
51
  let ProxyService = class ProxyService extends core_1.ProxyService {
52
- constructor(appConfigService, fs, dockerService) {
52
+ constructor(appService, processService, fs, dockerService) {
53
53
  super();
54
- this.appConfigService = appConfigService;
54
+ this.appService = appService;
55
+ this.processService = processService;
55
56
  this.fs = fs;
56
57
  this.dockerService = dockerService;
57
58
  this.containerName = "wocker-proxy";
58
59
  this.oldContainerNames = ["proxy.workspace"];
59
- this.imageName = "wocker-proxy:1.0.1";
60
+ this.imageName = "wocker-proxy:1.0.2";
60
61
  this.oldImages = [
61
- "wocker-proxy:1.0.0"
62
+ "wocker-proxy:1.0.0",
63
+ "wocker-proxy:1.0.1"
62
64
  ];
63
65
  }
64
66
  async init(project) {
65
- const appPort = await (0, utils_1.promptInput)({
67
+ const appPort = await (0, prompts_1.promptInput)({
66
68
  message: "App port",
67
69
  type: "number",
68
70
  default: parseInt(project.getEnv("VIRTUAL_PORT", "80"))
@@ -81,7 +83,6 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
81
83
  }
82
84
  console.info("Proxy starting...");
83
85
  await this.build(rebuild);
84
- const fs = this.fs;
85
86
  if (!this.fs.exists("certs/ca")) {
86
87
  this.fs.mkdir("certs/ca", {
87
88
  recursive: true,
@@ -94,35 +95,45 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
94
95
  mode: 0o700
95
96
  });
96
97
  }
97
- if (!fs.exists("nginx/vhost.d")) {
98
- fs.mkdir("nginx/vhost.d", {
98
+ if (!this.fs.exists("nginx/vhost.d")) {
99
+ this.fs.mkdir("nginx/vhost.d", {
99
100
  recursive: true,
100
101
  mode: 0o700
101
102
  });
102
103
  }
103
- const httpPort = this.appConfigService.getMeta("PROXY_HTTP_PORT", "80");
104
- const httpsPort = this.appConfigService.getMeta("PROXY_HTTPS_PORT", "443");
105
- const sshPort = this.appConfigService.getMeta("PROXY_SSH_PORT", "22");
104
+ if (!this.fs.exists("nginx/htpasswd")) {
105
+ this.fs.mkdir("nginx/htpasswd", {
106
+ recursive: true,
107
+ mode: 0o764
108
+ });
109
+ }
110
+ else {
111
+ this.fs.chmod("nginx/htpasswd", 0o764);
112
+ }
113
+ const httpPort = this.appService.getMeta("PROXY_HTTP_PORT", "80"), httpsPort = this.appService.getMeta("PROXY_HTTPS_PORT", "443"), sshPort = this.appService.getMeta("PROXY_SSH_PORT", "22");
106
114
  container = await this.dockerService.createContainer({
107
115
  name: this.containerName,
108
116
  image: this.imageName,
109
117
  restart: "always",
110
118
  env: {
119
+ UID: this.processService.UID,
120
+ GID: this.processService.GID,
111
121
  DEFAULT_HOST: "localhost",
112
122
  TRUST_DOWNSTREAM_PROXY: "true"
113
123
  },
114
124
  ports: [
115
125
  `${httpPort}:80`,
116
126
  `${httpsPort}:443`,
117
- ...this.appConfigService.getMeta("PROXY_SSH_PASSWORD") ? [
127
+ ...this.appService.getMeta("PROXY_SSH_PASSWORD") ? [
118
128
  `${sshPort}:22`
119
129
  ] : []
120
130
  ],
121
131
  volumes: [
122
132
  "/var/run/docker.sock:/tmp/docker.sock:ro",
123
- `${fs.path("certs/projects")}:/etc/nginx/certs`,
124
- `${fs.path("certs/ca")}:/etc/nginx/ca-certs`,
125
- `${fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`
133
+ `${this.fs.path("certs/projects")}:/etc/nginx/certs`,
134
+ `${this.fs.path("certs/ca")}:/etc/nginx/ca-certs`,
135
+ `${this.fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`,
136
+ `${this.fs.path("nginx/htpasswd")}:/etc/nginx/htpasswd`
126
137
  ],
127
138
  network: "workspace"
128
139
  });
@@ -150,9 +161,9 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
150
161
  }
151
162
  await this.dockerService.buildImage({
152
163
  tag: this.imageName,
153
- version: this.appConfigService.isExperimentalEnabled("buildKit") ? "2" : "1",
164
+ version: this.appService.isExperimentalEnabled("buildKit") ? "2" : "1",
154
165
  buildArgs: {
155
- SSH_PASSWORD: this.appConfigService.getMeta("PROXY_SSH_PASSWORD")
166
+ SSH_PASSWORD: this.appService.getMeta("PROXY_SSH_PASSWORD")
156
167
  },
157
168
  context: Path.join(env_1.PLUGINS_DIR, "proxy"),
158
169
  dockerfile: "./Dockerfile"
@@ -165,7 +176,8 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
165
176
  exports.ProxyService = ProxyService;
166
177
  exports.ProxyService = ProxyService = __decorate([
167
178
  (0, core_1.Injectable)("PROXY_SERVICE"),
168
- __metadata("design:paramtypes", [core_1.AppConfigService,
179
+ __metadata("design:paramtypes", [core_1.AppService,
180
+ core_1.ProcessService,
169
181
  core_1.AppFileSystemService,
170
182
  docker_module_1.DockerService])
171
183
  ], ProxyService);
@@ -1,6 +1,5 @@
1
1
  export * from "./escapeRegExp";
2
2
  export * from "./exec";
3
3
  export * from "./get-cursor-position";
4
- export * from "./injectVariables";
5
4
  export * from "./parse-table";
6
5
  export * from "./spawn";
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./escapeRegExp"), exports);
18
18
  __exportStar(require("./exec"), exports);
19
19
  __exportStar(require("./get-cursor-position"), exports);
20
- __exportStar(require("./injectVariables"), exports);
21
20
  __exportStar(require("./parse-table"), exports);
22
21
  __exportStar(require("./spawn"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
3
  "type": "commonjs",
4
- "version": "1.0.31",
4
+ "version": "1.1.0",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Docker workspace for web projects",
7
7
  "license": "MIT",
@@ -35,29 +35,21 @@
35
35
  "make-coverage-badge": "make-coverage-badge"
36
36
  },
37
37
  "dependencies": {
38
- "@wocker/core": "1.0.31",
39
- "@wocker/docker-module": "^0.0.6",
38
+ "@wocker/core": "1.1.0",
39
+ "@wocker/docker-module": "^1.0.0",
40
+ "@wocker/prompts": "^1.0.0",
40
41
  "@wocker/utils": "^2.0.6",
41
42
  "async-mutex": "^0.4.0",
42
- "axios": "^1.6.7",
43
- "child_process": "^1.0.2",
44
43
  "cli-table3": "^0.6.2",
45
- "docker-compose": "^1.2.0",
46
- "dockerode": "^4.0.2",
47
44
  "keytar": "^7.9.0",
48
- "md5": "^2.3.0",
49
- "protobufjs": "^7.5.1",
50
45
  "unzipper": "^0.12.3",
51
46
  "yoctocolors-cjs": "^2.1.2"
52
47
  },
53
48
  "devDependencies": {
54
- "@types/dockerode": "^3.3.23",
55
49
  "@types/jest": "^30.0.0",
56
- "@types/md5": "^2.3.2",
57
- "@types/mute-stream": "^0.0.4",
58
50
  "@types/node": "^24.5.2",
59
51
  "@types/unzipper": "^0.10.10",
60
- "@wocker/docker-mock-module": "^0.0.3",
52
+ "@wocker/docker-mock-module": "^1.0.0",
61
53
  "@wocker/testing": "^1.0.4",
62
54
  "jest": "^30.1.3",
63
55
  "make-coverage-badge": "^1.2.0",
@@ -1,14 +1,21 @@
1
- FROM nginxproxy/nginx-proxy:1.6.4-alpine
1
+ FROM nginxproxy/nginx-proxy:1.10.1-alpine
2
2
 
3
- ARG SSH_PASSWORD=''
3
+ ENV UID=1000 \
4
+ GID=1000
4
5
 
6
+ COPY ./wocker-entrypoint.sh /app/wocker-entrypoint.sh
5
7
  COPY ./bin/wocker-create-ca /usr/local/bin/wocker-create-ca
6
8
  COPY ./bin/wocker-create-cert /usr/local/bin/wocker-create-cert
7
9
  COPY ./bin/wocker-create-domains /usr/local/bin/wocker-create-domains
8
10
 
9
- RUN chmod +x /usr/local/bin/wocker-create-ca && \
11
+ RUN chmod +x /app/wocker-entrypoint.sh && \
12
+ chown root:root /app/wocker-entrypoint.sh && \
13
+ chmod +x /usr/local/bin/wocker-create-ca && \
10
14
  chmod +x /usr/local/bin/wocker-create-cert && \
11
- chmod +x /usr/local/bin/wocker-create-domains
15
+ chmod +x /usr/local/bin/wocker-create-domains && \
16
+ apk add --no-cache apache2-utils shadow
17
+
18
+ ARG SSH_PASSWORD=''
12
19
 
13
20
  RUN if [ -n "$SSH_PASSWORD" ]; then \
14
21
  apk update && apk add --no-cache openssh; \
@@ -21,3 +28,6 @@ RUN if [ -n "$SSH_PASSWORD" ]; then \
21
28
  ssh-keygen -A; \
22
29
  echo "sshd: /usr/sbin/sshd -D" >> /app/Procfile; \
23
30
  fi
31
+
32
+ ENTRYPOINT ["/app/wocker-entrypoint.sh"]
33
+ CMD ["forego", "start", "-r"]
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ UID=${UID:-1000}
6
+ GID=${GID:-1000}
7
+
8
+ groupmod -g ${GID} nginx
9
+ usermod -u ${UID} -g ${GID} nginx
10
+
11
+ exec /app/docker-entrypoint.sh "$@"
@@ -1,18 +0,0 @@
1
- import { AxiosHeaders, AxiosResponse } from "axios";
2
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
3
- export declare class Http {
4
- readonly method: HttpMethod;
5
- readonly url: string;
6
- body?: any;
7
- protected headers: AxiosHeaders;
8
- private constructor();
9
- withHeader(name: string, value: string): Http;
10
- withBody(body: any): Http;
11
- send(path: string): Promise<AxiosResponse>;
12
- static get(url: string): Http;
13
- static post(url: string): Http;
14
- static put(url: string): Http;
15
- static patch(url: string): Http;
16
- static delete(url: string): Http;
17
- }
18
- export {};
package/lib/makes/Http.js DELETED
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Http = void 0;
37
- const axios_1 = __importStar(require("axios"));
38
- class Http {
39
- constructor(method = "GET", url, body) {
40
- this.method = method;
41
- this.url = url;
42
- this.body = body;
43
- this.headers = new axios_1.AxiosHeaders();
44
- }
45
- withHeader(name, value) {
46
- this.headers.set(name, value);
47
- return this;
48
- }
49
- withBody(body) {
50
- this.body = body;
51
- return this;
52
- }
53
- async send(path) {
54
- return axios_1.default.create({
55
- method: this.method,
56
- baseURL: this.url,
57
- headers: this.headers.toJSON(),
58
- validateStatus() {
59
- return true;
60
- }
61
- }).request({
62
- url: path,
63
- data: this.body
64
- });
65
- }
66
- static get(url) {
67
- return new Http("GET", url);
68
- }
69
- static post(url) {
70
- return new Http("POST", url);
71
- }
72
- static put(url) {
73
- return new Http("PUT", url);
74
- }
75
- static patch(url) {
76
- return new Http("PATCH", url);
77
- }
78
- static delete(url) {
79
- return new Http("DELETE", url);
80
- }
81
- }
82
- exports.Http = Http;
@@ -1,22 +0,0 @@
1
- type VersionData = {
2
- major: number;
3
- minor: number;
4
- patch: number;
5
- tag?: string;
6
- build?: number;
7
- };
8
- export declare class Version {
9
- static readonly REGEXP: RegExp;
10
- protected static cache: Map<string, Version>;
11
- readonly major: number;
12
- readonly minor: number;
13
- readonly patch: number;
14
- readonly tag?: string;
15
- readonly build?: number;
16
- constructor(data: VersionData);
17
- parts(): number[];
18
- compare(version: string | Version): number;
19
- static valid(version: string): boolean;
20
- static parse(version: string): Version;
21
- }
22
- export {};
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Version = void 0;
4
- class Version {
5
- constructor(data) {
6
- Object.assign(this, data);
7
- }
8
- parts() {
9
- return [
10
- this.major,
11
- this.minor,
12
- this.patch,
13
- this.build ?? 0
14
- ];
15
- }
16
- compare(version) {
17
- if (typeof version === "string") {
18
- version = Version.parse(version);
19
- }
20
- const a = this.parts(), b = version.parts();
21
- for (let i = 0; i < Math.max(a.length, b.length); i++) {
22
- if (i === 3) {
23
- if (this.tag && !version.tag)
24
- return -1;
25
- else if (!this.tag && version.tag)
26
- return 1;
27
- else if (this.tag !== version.tag)
28
- return this.tag < version.tag ? -1 : 1;
29
- }
30
- const diff = (a[i] ?? 0) - (b[i] ?? 0);
31
- if (diff !== 0) {
32
- return diff > 0 ? 1 : -1;
33
- }
34
- }
35
- return 0;
36
- }
37
- static valid(version) {
38
- return Version.REGEXP.test(version);
39
- }
40
- static parse(version) {
41
- if (!Version.cache.has(version)) {
42
- if (!Version.REGEXP.test(version)) {
43
- throw new RangeError("Invalid version format");
44
- }
45
- const [, major, minor, patch, tag, build] = Version.REGEXP.exec(version) || [];
46
- Version.cache.set(version, new Version({
47
- major: parseInt(major),
48
- minor: parseInt(minor),
49
- patch: parseInt(patch),
50
- tag,
51
- build: build ? parseInt(build) : undefined
52
- }));
53
- }
54
- return Version.cache.get(version);
55
- }
56
- }
57
- exports.Version = Version;
58
- Version.REGEXP = /^v?(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)(?:\.(\d+))?)?/;
59
- Version.cache = new Map();
@@ -1,6 +0,0 @@
1
- import { VersionRule } from "./VersionRule";
2
- export declare class VersionRange {
3
- protected rules: VersionRule[][];
4
- constructor(rules: VersionRule[][]);
5
- static parse(range: string): VersionRange;
6
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VersionRange = void 0;
4
- const VersionRule_1 = require("./VersionRule");
5
- class VersionRange {
6
- constructor(rules) {
7
- this.rules = rules;
8
- }
9
- static parse(range) {
10
- const rules = range.split("||").map((range) => {
11
- return range.split(" ").map((rule) => {
12
- return VersionRule_1.VersionRule.parse(rule);
13
- });
14
- });
15
- return new VersionRange(rules);
16
- }
17
- }
18
- exports.VersionRange = VersionRange;
@@ -1,24 +0,0 @@
1
- import { Version } from "./Version";
2
- type VersionRuleData = {
3
- prefix?: string;
4
- major?: number;
5
- minor?: number;
6
- patch?: number;
7
- tag?: string;
8
- build?: number;
9
- };
10
- export declare class VersionRule {
11
- static readonly REGEXP: RegExp;
12
- protected static map: Map<string, VersionRule>;
13
- readonly prefix?: string;
14
- readonly major?: number;
15
- readonly minor?: number;
16
- readonly patch?: number;
17
- readonly tag?: string;
18
- readonly build?: number;
19
- constructor(data: VersionRuleData);
20
- get version(): Version;
21
- match(version: string | Version, withTag?: boolean): boolean;
22
- static parse(rule: string): VersionRule;
23
- }
24
- export {};