@namespacelabs/actions-toolkit 0.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.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Namespace Labs, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @namespacelabs/actions-toolkit
2
+
3
+ GitHub Actions toolkit for [Namespace](https://namespace.so).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @namespacelabs/actions-toolkit
9
+ ```
10
+
11
+ ## Packages
12
+
13
+ ### spacectl
14
+
15
+ Install and execute the [spacectl](https://github.com/namespacelabs/space) CLI.
16
+
17
+ ```typescript
18
+ import { install, exec } from "@namespacelabs/actions-toolkit/spacectl";
19
+
20
+ const { binPath, version } = await install();
21
+ const result = await exec(binPath, ["cache", "modes"]);
22
+ ```
23
+
24
+ See [spacectl documentation](src/spacectl/README.md) for detailed usage.
25
+
26
+ ## License
27
+
28
+ [Apache-2.0](LICENSE)
29
+
30
+ ## Contributing
31
+
32
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
33
+
34
+ ## Links
35
+
36
+ - [Namespace](https://namespace.so)
37
+ - [spacectl CLI](https://github.com/namespacelabs/space)
38
+ - [Documentation](https://namespace.so/docs)
@@ -0,0 +1,26 @@
1
+ import * as actionsExec from "@actions/exec";
2
+
3
+ //#region src/spacectl/exec.d.ts
4
+ type ExecOptions = Omit<actionsExec.ExecOptions, "listeners" | "ignoreReturnCode" | "silent">;
5
+ type ExecResult = actionsExec.ExecOutput;
6
+ declare function exec(binPath: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
7
+ //#endregion
8
+ //#region src/spacectl/installer.d.ts
9
+ interface InstallOptions {
10
+ version?: string;
11
+ githubToken?: string;
12
+ }
13
+ interface InstallResult {
14
+ binPath: string;
15
+ version: string;
16
+ }
17
+ type SpacectlInstallErrorCode = "UNSUPPORTED_PLATFORM" | "RESOLVE_VERSION_FAILED" | "DOWNLOAD_FAILED" | "EXEC_FAILED";
18
+ declare class SpacectlInstallError extends Error {
19
+ readonly code: SpacectlInstallErrorCode;
20
+ readonly cause?: unknown;
21
+ constructor(message: string, code: SpacectlInstallErrorCode, cause?: unknown);
22
+ }
23
+ declare function install(options?: InstallOptions): Promise<InstallResult>;
24
+ //#endregion
25
+ export { ExecOptions as a, install as i, InstallResult as n, ExecResult as o, SpacectlInstallError as r, exec as s, InstallOptions as t };
26
+ //# sourceMappingURL=index-C6FXIu0Q.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-C6FXIu0Q.d.mts","names":[],"sources":["../src/spacectl/exec.ts","../src/spacectl/installer.ts"],"mappings":";;;KAGY,WAAA,GAAc,IAAA,CACxB,WAAA,CAAY,WAAA;AAAA,KAIF,UAAA,GAAa,WAAA,CAAY,UAAA;AAAA,iBAEf,IAAA,CACpB,OAAA,UACA,IAAA,YACA,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,UAAA;;;UCDM,cAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,aAAA;EACf,OAAA;EACA,OAAA;AAAA;AAAA,KAGU,wBAAA;AAAA,cAMC,oBAAA,SAA6B,KAAA;EAAA,SAC/B,IAAA,EAAM,wBAAA;EAAA,SACN,KAAA;cAEG,OAAA,UAAiB,IAAA,EAAM,wBAAA,EAA0B,KAAA;AAAA;AAAA,iBAkFzC,OAAA,CAAQ,OAAA,GAAS,cAAA,GAAsB,OAAA,CAAQ,aAAA"}
@@ -0,0 +1,26 @@
1
+ import * as actionsExec from "@actions/exec";
2
+
3
+ //#region src/spacectl/exec.d.ts
4
+ type ExecOptions = Omit<actionsExec.ExecOptions, "listeners" | "ignoreReturnCode" | "silent">;
5
+ type ExecResult = actionsExec.ExecOutput;
6
+ declare function exec(binPath: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
7
+ //#endregion
8
+ //#region src/spacectl/installer.d.ts
9
+ interface InstallOptions {
10
+ version?: string;
11
+ githubToken?: string;
12
+ }
13
+ interface InstallResult {
14
+ binPath: string;
15
+ version: string;
16
+ }
17
+ type SpacectlInstallErrorCode = "UNSUPPORTED_PLATFORM" | "RESOLVE_VERSION_FAILED" | "DOWNLOAD_FAILED" | "EXEC_FAILED";
18
+ declare class SpacectlInstallError extends Error {
19
+ readonly code: SpacectlInstallErrorCode;
20
+ readonly cause?: unknown;
21
+ constructor(message: string, code: SpacectlInstallErrorCode, cause?: unknown);
22
+ }
23
+ declare function install(options?: InstallOptions): Promise<InstallResult>;
24
+ //#endregion
25
+ export { ExecOptions as a, install as i, InstallResult as n, ExecResult as o, SpacectlInstallError as r, exec as s, InstallOptions as t };
26
+ //# sourceMappingURL=index-DJzkZaGq.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DJzkZaGq.d.cts","names":[],"sources":["../src/spacectl/exec.ts","../src/spacectl/installer.ts"],"mappings":";;;KAGY,WAAA,GAAc,IAAA,CACxB,WAAA,CAAY,WAAA;AAAA,KAIF,UAAA,GAAa,WAAA,CAAY,UAAA;AAAA,iBAEf,IAAA,CACpB,OAAA,UACA,IAAA,YACA,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,UAAA;;;UCDM,cAAA;EACf,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,aAAA;EACf,OAAA;EACA,OAAA;AAAA;AAAA,KAGU,wBAAA;AAAA,cAMC,oBAAA,SAA6B,KAAA;EAAA,SAC/B,IAAA,EAAM,wBAAA;EAAA,SACN,KAAA;cAEG,OAAA,UAAiB,IAAA,EAAM,wBAAA,EAA0B,KAAA;AAAA;AAAA,iBAkFzC,OAAA,CAAQ,OAAA,GAAS,cAAA,GAAsB,OAAA,CAAQ,aAAA"}
package/dist/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const require_spacectl = require('./spacectl-6udimwjI.cjs');
2
+
3
+ exports.SpacectlInstallError = require_spacectl.SpacectlInstallError;
4
+ exports.exec = require_spacectl.exec;
5
+ exports.install = require_spacectl.install;
@@ -0,0 +1,2 @@
1
+ import { a as ExecOptions, i as install, n as InstallResult, o as ExecResult, r as SpacectlInstallError, s as exec, t as InstallOptions } from "./index-DJzkZaGq.cjs";
2
+ export { ExecOptions, ExecResult, InstallOptions, InstallResult, SpacectlInstallError, exec, install };
@@ -0,0 +1,2 @@
1
+ import { a as ExecOptions, i as install, n as InstallResult, o as ExecResult, r as SpacectlInstallError, s as exec, t as InstallOptions } from "./index-C6FXIu0Q.mjs";
2
+ export { ExecOptions, ExecResult, InstallOptions, InstallResult, SpacectlInstallError, exec, install };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { n as install, r as exec, t as SpacectlInstallError } from "./spacectl-COQOkFHx.mjs";
2
+
3
+ export { SpacectlInstallError, exec, install };
@@ -0,0 +1,273 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+ let _actions_core = require("@actions/core");
29
+ _actions_core = __toESM(_actions_core);
30
+ let _actions_exec = require("@actions/exec");
31
+ _actions_exec = __toESM(_actions_exec);
32
+ let node_path = require("node:path");
33
+ node_path = __toESM(node_path);
34
+ let _actions_io = require("@actions/io");
35
+ _actions_io = __toESM(_actions_io);
36
+ let _actions_tool_cache = require("@actions/tool-cache");
37
+ _actions_tool_cache = __toESM(_actions_tool_cache);
38
+ let node_os = require("node:os");
39
+ node_os = __toESM(node_os);
40
+ let _actions_github = require("@actions/github");
41
+ _actions_github = __toESM(_actions_github);
42
+
43
+ //#region src/spacectl/exec.ts
44
+ async function exec(binPath, args, options) {
45
+ const execArgs = [...args, "--output=json"];
46
+ let stdout = "";
47
+ let stderr = "";
48
+ const exitCode = await _actions_exec.exec(binPath, execArgs, {
49
+ ...options,
50
+ ignoreReturnCode: true,
51
+ silent: true,
52
+ listeners: {
53
+ stdout: (data) => {
54
+ stdout += data.toString();
55
+ },
56
+ stderr: (data) => {
57
+ stderr += data.toString();
58
+ process.stdout.write(data);
59
+ }
60
+ }
61
+ });
62
+ if (exitCode !== 0) {
63
+ let errorMessage = `'${binPath} ${execArgs.join(" ")}' failed with exit code ${exitCode}`;
64
+ try {
65
+ const errorJson = JSON.parse(stdout.trim());
66
+ if (errorJson.message) errorMessage = errorJson.message;
67
+ } catch {}
68
+ _actions_core.error(errorMessage);
69
+ process.exit(exitCode);
70
+ }
71
+ return {
72
+ exitCode,
73
+ stdout,
74
+ stderr
75
+ };
76
+ }
77
+
78
+ //#endregion
79
+ //#region src/spacectl/platform.ts
80
+ function getPlatform() {
81
+ const platform = node_os.platform();
82
+ switch (platform) {
83
+ case "darwin": return "darwin";
84
+ case "linux": return "linux";
85
+ case "win32": return "windows";
86
+ default: throw new Error(`Unsupported platform: ${platform}`);
87
+ }
88
+ }
89
+ function getArch() {
90
+ switch (node_os.arch()) {
91
+ case "arm64": return "arm64";
92
+ case "x64": return "amd64";
93
+ default: return "amd64";
94
+ }
95
+ }
96
+ function getBinaryName() {
97
+ return getPlatform() === "windows" ? "space.exe" : "space";
98
+ }
99
+
100
+ //#endregion
101
+ //#region src/spacectl/version.ts
102
+ const REPO_OWNER$1 = "namespacelabs";
103
+ const REPO_NAME$1 = "space";
104
+ function normalizeVersion(version) {
105
+ return version.trim().replace(/^v/, "");
106
+ }
107
+ async function getLatestVersion(token) {
108
+ const octokit = _actions_github.getOctokit(token || process.env.GITHUB_TOKEN || "");
109
+ try {
110
+ const { data: release } = await octokit.rest.repos.getLatestRelease({
111
+ owner: REPO_OWNER$1,
112
+ repo: REPO_NAME$1
113
+ });
114
+ return normalizeVersion(release.tag_name);
115
+ } catch (error) {
116
+ _actions_core.debug(`Failed to get latest release: ${error}`);
117
+ throw new Error("Failed to resolve latest version. If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.");
118
+ }
119
+ }
120
+ async function getLatestDevVersion(token) {
121
+ const octokit = _actions_github.getOctokit(token || process.env.GITHUB_TOKEN || "");
122
+ try {
123
+ const iterator = octokit.paginate.iterator(octokit.rest.repos.listReleases, {
124
+ owner: REPO_OWNER$1,
125
+ repo: REPO_NAME$1,
126
+ per_page: 100
127
+ });
128
+ for await (const { data: releases } of iterator) for (const release of releases) if (release.tag_name.includes("-dev")) return normalizeVersion(release.tag_name);
129
+ throw new Error("No dev release found");
130
+ } catch (error) {
131
+ _actions_core.debug(`Failed to get dev release: ${error}`);
132
+ throw new Error("Failed to resolve dev version. If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.");
133
+ }
134
+ }
135
+ async function resolveVersion(versionSpec, token) {
136
+ const spec = versionSpec.trim().toLowerCase();
137
+ if (spec === "" || spec === "latest") return getLatestVersion(token);
138
+ if (spec === "dev") return getLatestDevVersion(token);
139
+ return normalizeVersion(versionSpec);
140
+ }
141
+
142
+ //#endregion
143
+ //#region src/spacectl/installer.ts
144
+ const TOOL_NAME = "space";
145
+ const REPO_OWNER = "namespacelabs";
146
+ const REPO_NAME = "space";
147
+ var SpacectlInstallError = class extends Error {
148
+ code;
149
+ cause;
150
+ constructor(message, code, cause) {
151
+ super(message);
152
+ this.name = "SpacectlInstallError";
153
+ this.code = code;
154
+ this.cause = cause;
155
+ }
156
+ };
157
+ async function findExistingBinary() {
158
+ const binaryName = getBinaryName();
159
+ const powertoysDir = process.env.NSC_POWERTOYS_DIR;
160
+ if (powertoysDir) {
161
+ const powertoysPath = node_path.join(powertoysDir, binaryName);
162
+ try {
163
+ await _actions_io.which(powertoysPath, true);
164
+ _actions_core.debug(`Found existing binary in powertoys: ${powertoysPath}`);
165
+ return powertoysPath;
166
+ } catch {
167
+ _actions_core.debug(`Binary not found in powertoys dir: ${powertoysPath}`);
168
+ }
169
+ }
170
+ try {
171
+ const systemPath = await _actions_io.which(TOOL_NAME, true);
172
+ _actions_core.debug(`Found existing binary on PATH: ${systemPath}`);
173
+ return systemPath;
174
+ } catch {
175
+ _actions_core.debug("Binary not found on PATH");
176
+ }
177
+ }
178
+ async function getInstalledVersion(binPath) {
179
+ const result = await exec(binPath, ["version"]);
180
+ try {
181
+ return normalizeVersion(JSON.parse(result.stdout.trim()).version);
182
+ } catch (error) {
183
+ _actions_core.debug(`Failed to parse version output: ${error}`);
184
+ throw new SpacectlInstallError(`Failed to validate binary at ${binPath}`, "EXEC_FAILED", error);
185
+ }
186
+ }
187
+ function getDownloadUrl(version) {
188
+ return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${version}/${`${TOOL_NAME}_${version}_${getPlatform()}_${getArch()}.tar.gz`}`;
189
+ }
190
+ async function downloadAndCache(version, token) {
191
+ const platform = getPlatform();
192
+ const arch = getArch();
193
+ const url = getDownloadUrl(version);
194
+ _actions_core.info(`Downloading spacectl ${version} from ${url}`);
195
+ let archivePath;
196
+ try {
197
+ const headers = {};
198
+ if (token) headers["Authorization"] = `token ${token}`;
199
+ archivePath = await _actions_tool_cache.downloadTool(url, void 0, void 0, headers);
200
+ } catch (error) {
201
+ throw new SpacectlInstallError(`Failed to download spacectl ${version} for ${platform}/${arch}`, "DOWNLOAD_FAILED", error);
202
+ }
203
+ const extractedPath = await _actions_tool_cache.extractTar(archivePath);
204
+ const cachedPath = await _actions_tool_cache.cacheDir(extractedPath, TOOL_NAME, version, arch);
205
+ _actions_core.info(`Cached spacectl ${version} to ${cachedPath}`);
206
+ return cachedPath;
207
+ }
208
+ async function install(options = {}) {
209
+ const versionSpec = options.version ?? "";
210
+ const token = options.githubToken ?? process.env.GITHUB_TOKEN;
211
+ try {
212
+ getPlatform();
213
+ } catch (error) {
214
+ throw new SpacectlInstallError(`Unsupported platform: ${process.platform}`, "UNSUPPORTED_PLATFORM", error);
215
+ }
216
+ const arch = getArch();
217
+ const binaryName = getBinaryName();
218
+ if (versionSpec === "") {
219
+ const existingPath = await findExistingBinary();
220
+ if (existingPath) {
221
+ const version = await getInstalledVersion(existingPath);
222
+ _actions_core.info(`Using existing spacectl ${version} at ${existingPath}`);
223
+ return {
224
+ binPath: existingPath,
225
+ version
226
+ };
227
+ }
228
+ _actions_core.info("No existing spacectl found, downloading latest version");
229
+ }
230
+ let targetVersion;
231
+ try {
232
+ targetVersion = versionSpec === "" ? await resolveVersion("latest", token) : await resolveVersion(versionSpec, token);
233
+ } catch (error) {
234
+ throw new SpacectlInstallError(`Failed to resolve version "${versionSpec}"`, "RESOLVE_VERSION_FAILED", error);
235
+ }
236
+ const cached = _actions_tool_cache.find(TOOL_NAME, targetVersion, arch);
237
+ if (cached) {
238
+ const binPath = node_path.join(cached, binaryName);
239
+ _actions_core.info(`Using cached spacectl ${targetVersion} at ${cached}`);
240
+ return {
241
+ binPath,
242
+ version: targetVersion
243
+ };
244
+ }
245
+ const cachedDir = await downloadAndCache(targetVersion, token);
246
+ const binPath = node_path.join(cachedDir, binaryName);
247
+ await getInstalledVersion(binPath);
248
+ return {
249
+ binPath,
250
+ version: targetVersion
251
+ };
252
+ }
253
+
254
+ //#endregion
255
+ Object.defineProperty(exports, 'SpacectlInstallError', {
256
+ enumerable: true,
257
+ get: function () {
258
+ return SpacectlInstallError;
259
+ }
260
+ });
261
+ Object.defineProperty(exports, 'exec', {
262
+ enumerable: true,
263
+ get: function () {
264
+ return exec;
265
+ }
266
+ });
267
+ Object.defineProperty(exports, 'install', {
268
+ enumerable: true,
269
+ get: function () {
270
+ return install;
271
+ }
272
+ });
273
+ //# sourceMappingURL=spacectl-6udimwjI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacectl-6udimwjI.cjs","names":["actionsExec","os","REPO_OWNER","REPO_NAME","github","path","io","tc"],"sources":["../src/spacectl/exec.ts","../src/spacectl/platform.ts","../src/spacectl/version.ts","../src/spacectl/installer.ts"],"sourcesContent":["import * as core from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\n\nexport type ExecOptions = Omit<\n actionsExec.ExecOptions,\n \"listeners\" | \"ignoreReturnCode\" | \"silent\"\n>;\n\nexport type ExecResult = actionsExec.ExecOutput;\n\nexport async function exec(\n binPath: string,\n args: string[],\n options?: ExecOptions\n): Promise<ExecResult> {\n const execArgs = [...args, \"--output=json\"];\n\n let stdout = \"\";\n let stderr = \"\";\n\n const exitCode = await actionsExec.exec(binPath, execArgs, {\n ...options,\n ignoreReturnCode: true,\n silent: true,\n listeners: {\n stdout: (data: Buffer) => {\n stdout += data.toString();\n },\n stderr: (data: Buffer) => {\n stderr += data.toString();\n // Forward stderr to stdout so GitHub Actions can process workflow\n // commands like ::debug::. The space binary outputs these to stderr\n // when --output=json is used to keep stdout clean for JSON.\n process.stdout.write(data);\n },\n },\n });\n\n if (exitCode !== 0) {\n let errorMessage = `'${binPath} ${execArgs.join(\" \")}' failed with exit code ${exitCode}`;\n try {\n const errorJson = JSON.parse(stdout.trim());\n if (errorJson.message) {\n errorMessage = errorJson.message;\n }\n } catch {\n // stdout wasn't valid JSON, use default message\n }\n core.error(errorMessage);\n process.exit(exitCode);\n }\n\n return { exitCode, stdout, stderr };\n}\n","import * as os from \"node:os\";\n\nexport type Platform = \"darwin\" | \"linux\" | \"windows\";\nexport type Arch = \"amd64\" | \"arm64\";\n\nexport function getPlatform(): Platform {\n const platform = os.platform();\n switch (platform) {\n case \"darwin\":\n return \"darwin\";\n case \"linux\":\n return \"linux\";\n case \"win32\":\n return \"windows\";\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n}\n\nexport function getArch(): Arch {\n const arch = os.arch();\n switch (arch) {\n case \"arm64\":\n return \"arm64\";\n case \"x64\":\n return \"amd64\";\n default:\n return \"amd64\";\n }\n}\n\nexport function getBinaryName(): string {\n return getPlatform() === \"windows\" ? \"space.exe\" : \"space\";\n}\n","import * as core from \"@actions/core\";\nimport * as github from \"@actions/github\";\n\nconst REPO_OWNER = \"namespacelabs\";\nconst REPO_NAME = \"space\";\n\nexport function normalizeVersion(version: string): string {\n return version.trim().replace(/^v/, \"\");\n}\n\nexport async function getLatestVersion(token?: string): Promise<string> {\n const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || \"\");\n\n try {\n const { data: release } = await octokit.rest.repos.getLatestRelease({\n owner: REPO_OWNER,\n repo: REPO_NAME,\n });\n return normalizeVersion(release.tag_name);\n } catch (error) {\n core.debug(`Failed to get latest release: ${error}`);\n throw new Error(\n `Failed to resolve latest version. ` +\n `If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.`\n );\n }\n}\n\nexport async function getLatestDevVersion(token?: string): Promise<string> {\n const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || \"\");\n\n try {\n const iterator = octokit.paginate.iterator(octokit.rest.repos.listReleases, {\n owner: REPO_OWNER,\n repo: REPO_NAME,\n per_page: 100,\n });\n\n for await (const { data: releases } of iterator) {\n for (const release of releases) {\n if (release.tag_name.includes(\"-dev\")) {\n return normalizeVersion(release.tag_name);\n }\n }\n }\n\n throw new Error(\"No dev release found\");\n } catch (error) {\n core.debug(`Failed to get dev release: ${error}`);\n throw new Error(\n `Failed to resolve dev version. ` +\n `If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.`\n );\n }\n}\n\nexport async function resolveVersion(versionSpec: string, token?: string): Promise<string> {\n const spec = versionSpec.trim().toLowerCase();\n\n if (spec === \"\" || spec === \"latest\") {\n return getLatestVersion(token);\n }\n\n if (spec === \"dev\") {\n return getLatestDevVersion(token);\n }\n\n return normalizeVersion(versionSpec);\n}\n","import * as path from \"node:path\";\nimport * as core from \"@actions/core\";\nimport * as io from \"@actions/io\";\nimport * as tc from \"@actions/tool-cache\";\n\nimport { exec } from \"./exec\";\nimport { getPlatform, getArch, getBinaryName } from \"./platform\";\nimport { resolveVersion, normalizeVersion } from \"./version\";\n\nconst TOOL_NAME = \"space\";\nconst REPO_OWNER = \"namespacelabs\";\nconst REPO_NAME = \"space\";\n\nexport interface InstallOptions {\n version?: string;\n githubToken?: string;\n}\n\nexport interface InstallResult {\n binPath: string;\n version: string;\n}\n\nexport type SpacectlInstallErrorCode =\n | \"UNSUPPORTED_PLATFORM\"\n | \"RESOLVE_VERSION_FAILED\"\n | \"DOWNLOAD_FAILED\"\n | \"EXEC_FAILED\";\n\nexport class SpacectlInstallError extends Error {\n readonly code: SpacectlInstallErrorCode;\n readonly cause?: unknown;\n\n constructor(message: string, code: SpacectlInstallErrorCode, cause?: unknown) {\n super(message);\n this.name = \"SpacectlInstallError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\nasync function findExistingBinary(): Promise<string | undefined> {\n const binaryName = getBinaryName();\n\n const powertoysDir = process.env.NSC_POWERTOYS_DIR;\n if (powertoysDir) {\n const powertoysPath = path.join(powertoysDir, binaryName);\n try {\n await io.which(powertoysPath, true);\n core.debug(`Found existing binary in powertoys: ${powertoysPath}`);\n return powertoysPath;\n } catch {\n core.debug(`Binary not found in powertoys dir: ${powertoysPath}`);\n }\n }\n\n try {\n const systemPath = await io.which(TOOL_NAME, true);\n core.debug(`Found existing binary on PATH: ${systemPath}`);\n return systemPath;\n } catch {\n core.debug(\"Binary not found on PATH\");\n }\n\n return undefined;\n}\n\nasync function getInstalledVersion(binPath: string): Promise<string> {\n const result = await exec(binPath, [\"version\"]);\n\n try {\n const parsed = JSON.parse(result.stdout.trim());\n return normalizeVersion(parsed.version);\n } catch (error) {\n core.debug(`Failed to parse version output: ${error}`);\n throw new SpacectlInstallError(`Failed to validate binary at ${binPath}`, \"EXEC_FAILED\", error);\n }\n}\n\nfunction getDownloadUrl(version: string): string {\n const platform = getPlatform();\n const arch = getArch();\n const filename = `${TOOL_NAME}_${version}_${platform}_${arch}.tar.gz`;\n return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${version}/${filename}`;\n}\n\nasync function downloadAndCache(version: string, token?: string): Promise<string> {\n const platform = getPlatform();\n const arch = getArch();\n const url = getDownloadUrl(version);\n\n core.info(`Downloading spacectl ${version} from ${url}`);\n\n let archivePath: string;\n try {\n const headers: Record<string, string> = {};\n if (token) {\n headers[\"Authorization\"] = `token ${token}`;\n }\n archivePath = await tc.downloadTool(url, undefined, undefined, headers);\n } catch (error) {\n throw new SpacectlInstallError(\n `Failed to download spacectl ${version} for ${platform}/${arch}`,\n \"DOWNLOAD_FAILED\",\n error\n );\n }\n\n const extractedPath = await tc.extractTar(archivePath);\n const cachedPath = await tc.cacheDir(extractedPath, TOOL_NAME, version, arch);\n\n core.info(`Cached spacectl ${version} to ${cachedPath}`);\n return cachedPath;\n}\n\nexport async function install(options: InstallOptions = {}): Promise<InstallResult> {\n const versionSpec = options.version ?? \"\";\n const token = options.githubToken ?? process.env.GITHUB_TOKEN;\n\n try {\n getPlatform();\n } catch (error) {\n throw new SpacectlInstallError(\n `Unsupported platform: ${process.platform}`,\n \"UNSUPPORTED_PLATFORM\",\n error\n );\n }\n\n const arch = getArch();\n const binaryName = getBinaryName();\n\n if (versionSpec === \"\") {\n const existingPath = await findExistingBinary();\n if (existingPath) {\n const version = await getInstalledVersion(existingPath);\n core.info(`Using existing spacectl ${version} at ${existingPath}`);\n return {\n binPath: existingPath,\n version,\n };\n }\n core.info(\"No existing spacectl found, downloading latest version\");\n }\n\n let targetVersion: string;\n try {\n targetVersion =\n versionSpec === \"\"\n ? await resolveVersion(\"latest\", token)\n : await resolveVersion(versionSpec, token);\n } catch (error) {\n throw new SpacectlInstallError(\n `Failed to resolve version \"${versionSpec}\"`,\n \"RESOLVE_VERSION_FAILED\",\n error\n );\n }\n\n const cached = tc.find(TOOL_NAME, targetVersion, arch);\n if (cached) {\n const binPath = path.join(cached, binaryName);\n core.info(`Using cached spacectl ${targetVersion} at ${cached}`);\n return {\n binPath,\n version: targetVersion,\n };\n }\n\n const cachedDir = await downloadAndCache(targetVersion, token);\n const binPath = path.join(cachedDir, binaryName);\n\n await getInstalledVersion(binPath);\n\n return {\n binPath,\n version: targetVersion,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,eAAsB,KACpB,SACA,MACA,SACqB;CACrB,MAAM,WAAW,CAAC,GAAG,MAAM,gBAAgB;CAE3C,IAAI,SAAS;CACb,IAAI,SAAS;CAEb,MAAM,WAAW,MAAMA,cAAY,KAAK,SAAS,UAAU;EACzD,GAAG;EACH,kBAAkB;EAClB,QAAQ;EACR,WAAW;GACT,SAAS,SAAiB;AACxB,cAAU,KAAK,UAAU;;GAE3B,SAAS,SAAiB;AACxB,cAAU,KAAK,UAAU;AAIzB,YAAQ,OAAO,MAAM,KAAK;;GAE7B;EACF,CAAC;AAEF,KAAI,aAAa,GAAG;EAClB,IAAI,eAAe,IAAI,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAC,0BAA0B;AAC/E,MAAI;GACF,MAAM,YAAY,KAAK,MAAM,OAAO,MAAM,CAAC;AAC3C,OAAI,UAAU,QACZ,gBAAe,UAAU;UAErB;AAGR,gBAAK,MAAM,aAAa;AACxB,UAAQ,KAAK,SAAS;;AAGxB,QAAO;EAAE;EAAU;EAAQ;EAAQ;;;;;AC/CrC,SAAgB,cAAwB;CACtC,MAAM,WAAWC,QAAG,UAAU;AAC9B,SAAQ,UAAR;EACE,KAAK,SACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,KAAK,QACH,QAAO;EACT,QACE,OAAM,IAAI,MAAM,yBAAyB,WAAW;;;AAI1D,SAAgB,UAAgB;AAE9B,SADaA,QAAG,MAAM,EACtB;EACE,KAAK,QACH,QAAO;EACT,KAAK,MACH,QAAO;EACT,QACE,QAAO;;;AAIb,SAAgB,gBAAwB;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AUA,UAAK,KAAK,WAAW,WAAW;AAEhD,OAAM,oBAAoB,QAAQ;AAElC,QAAO;EACL;EACA,SAAS;EACV"}
@@ -0,0 +1,222 @@
1
+ import * as core from "@actions/core";
2
+ import * as actionsExec from "@actions/exec";
3
+ import * as path from "node:path";
4
+ import * as io from "@actions/io";
5
+ import * as tc from "@actions/tool-cache";
6
+ import * as os from "node:os";
7
+ import * as github from "@actions/github";
8
+
9
+ //#region src/spacectl/exec.ts
10
+ async function exec(binPath, args, options) {
11
+ const execArgs = [...args, "--output=json"];
12
+ let stdout = "";
13
+ let stderr = "";
14
+ const exitCode = await actionsExec.exec(binPath, execArgs, {
15
+ ...options,
16
+ ignoreReturnCode: true,
17
+ silent: true,
18
+ listeners: {
19
+ stdout: (data) => {
20
+ stdout += data.toString();
21
+ },
22
+ stderr: (data) => {
23
+ stderr += data.toString();
24
+ process.stdout.write(data);
25
+ }
26
+ }
27
+ });
28
+ if (exitCode !== 0) {
29
+ let errorMessage = `'${binPath} ${execArgs.join(" ")}' failed with exit code ${exitCode}`;
30
+ try {
31
+ const errorJson = JSON.parse(stdout.trim());
32
+ if (errorJson.message) errorMessage = errorJson.message;
33
+ } catch {}
34
+ core.error(errorMessage);
35
+ process.exit(exitCode);
36
+ }
37
+ return {
38
+ exitCode,
39
+ stdout,
40
+ stderr
41
+ };
42
+ }
43
+
44
+ //#endregion
45
+ //#region src/spacectl/platform.ts
46
+ function getPlatform() {
47
+ const platform = os.platform();
48
+ switch (platform) {
49
+ case "darwin": return "darwin";
50
+ case "linux": return "linux";
51
+ case "win32": return "windows";
52
+ default: throw new Error(`Unsupported platform: ${platform}`);
53
+ }
54
+ }
55
+ function getArch() {
56
+ switch (os.arch()) {
57
+ case "arm64": return "arm64";
58
+ case "x64": return "amd64";
59
+ default: return "amd64";
60
+ }
61
+ }
62
+ function getBinaryName() {
63
+ return getPlatform() === "windows" ? "space.exe" : "space";
64
+ }
65
+
66
+ //#endregion
67
+ //#region src/spacectl/version.ts
68
+ const REPO_OWNER$1 = "namespacelabs";
69
+ const REPO_NAME$1 = "space";
70
+ function normalizeVersion(version) {
71
+ return version.trim().replace(/^v/, "");
72
+ }
73
+ async function getLatestVersion(token) {
74
+ const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || "");
75
+ try {
76
+ const { data: release } = await octokit.rest.repos.getLatestRelease({
77
+ owner: REPO_OWNER$1,
78
+ repo: REPO_NAME$1
79
+ });
80
+ return normalizeVersion(release.tag_name);
81
+ } catch (error) {
82
+ core.debug(`Failed to get latest release: ${error}`);
83
+ throw new Error("Failed to resolve latest version. If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.");
84
+ }
85
+ }
86
+ async function getLatestDevVersion(token) {
87
+ const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || "");
88
+ try {
89
+ const iterator = octokit.paginate.iterator(octokit.rest.repos.listReleases, {
90
+ owner: REPO_OWNER$1,
91
+ repo: REPO_NAME$1,
92
+ per_page: 100
93
+ });
94
+ for await (const { data: releases } of iterator) for (const release of releases) if (release.tag_name.includes("-dev")) return normalizeVersion(release.tag_name);
95
+ throw new Error("No dev release found");
96
+ } catch (error) {
97
+ core.debug(`Failed to get dev release: ${error}`);
98
+ throw new Error("Failed to resolve dev version. If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.");
99
+ }
100
+ }
101
+ async function resolveVersion(versionSpec, token) {
102
+ const spec = versionSpec.trim().toLowerCase();
103
+ if (spec === "" || spec === "latest") return getLatestVersion(token);
104
+ if (spec === "dev") return getLatestDevVersion(token);
105
+ return normalizeVersion(versionSpec);
106
+ }
107
+
108
+ //#endregion
109
+ //#region src/spacectl/installer.ts
110
+ const TOOL_NAME = "space";
111
+ const REPO_OWNER = "namespacelabs";
112
+ const REPO_NAME = "space";
113
+ var SpacectlInstallError = class extends Error {
114
+ code;
115
+ cause;
116
+ constructor(message, code, cause) {
117
+ super(message);
118
+ this.name = "SpacectlInstallError";
119
+ this.code = code;
120
+ this.cause = cause;
121
+ }
122
+ };
123
+ async function findExistingBinary() {
124
+ const binaryName = getBinaryName();
125
+ const powertoysDir = process.env.NSC_POWERTOYS_DIR;
126
+ if (powertoysDir) {
127
+ const powertoysPath = path.join(powertoysDir, binaryName);
128
+ try {
129
+ await io.which(powertoysPath, true);
130
+ core.debug(`Found existing binary in powertoys: ${powertoysPath}`);
131
+ return powertoysPath;
132
+ } catch {
133
+ core.debug(`Binary not found in powertoys dir: ${powertoysPath}`);
134
+ }
135
+ }
136
+ try {
137
+ const systemPath = await io.which(TOOL_NAME, true);
138
+ core.debug(`Found existing binary on PATH: ${systemPath}`);
139
+ return systemPath;
140
+ } catch {
141
+ core.debug("Binary not found on PATH");
142
+ }
143
+ }
144
+ async function getInstalledVersion(binPath) {
145
+ const result = await exec(binPath, ["version"]);
146
+ try {
147
+ return normalizeVersion(JSON.parse(result.stdout.trim()).version);
148
+ } catch (error) {
149
+ core.debug(`Failed to parse version output: ${error}`);
150
+ throw new SpacectlInstallError(`Failed to validate binary at ${binPath}`, "EXEC_FAILED", error);
151
+ }
152
+ }
153
+ function getDownloadUrl(version) {
154
+ return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${version}/${`${TOOL_NAME}_${version}_${getPlatform()}_${getArch()}.tar.gz`}`;
155
+ }
156
+ async function downloadAndCache(version, token) {
157
+ const platform = getPlatform();
158
+ const arch = getArch();
159
+ const url = getDownloadUrl(version);
160
+ core.info(`Downloading spacectl ${version} from ${url}`);
161
+ let archivePath;
162
+ try {
163
+ const headers = {};
164
+ if (token) headers["Authorization"] = `token ${token}`;
165
+ archivePath = await tc.downloadTool(url, void 0, void 0, headers);
166
+ } catch (error) {
167
+ throw new SpacectlInstallError(`Failed to download spacectl ${version} for ${platform}/${arch}`, "DOWNLOAD_FAILED", error);
168
+ }
169
+ const extractedPath = await tc.extractTar(archivePath);
170
+ const cachedPath = await tc.cacheDir(extractedPath, TOOL_NAME, version, arch);
171
+ core.info(`Cached spacectl ${version} to ${cachedPath}`);
172
+ return cachedPath;
173
+ }
174
+ async function install(options = {}) {
175
+ const versionSpec = options.version ?? "";
176
+ const token = options.githubToken ?? process.env.GITHUB_TOKEN;
177
+ try {
178
+ getPlatform();
179
+ } catch (error) {
180
+ throw new SpacectlInstallError(`Unsupported platform: ${process.platform}`, "UNSUPPORTED_PLATFORM", error);
181
+ }
182
+ const arch = getArch();
183
+ const binaryName = getBinaryName();
184
+ if (versionSpec === "") {
185
+ const existingPath = await findExistingBinary();
186
+ if (existingPath) {
187
+ const version = await getInstalledVersion(existingPath);
188
+ core.info(`Using existing spacectl ${version} at ${existingPath}`);
189
+ return {
190
+ binPath: existingPath,
191
+ version
192
+ };
193
+ }
194
+ core.info("No existing spacectl found, downloading latest version");
195
+ }
196
+ let targetVersion;
197
+ try {
198
+ targetVersion = versionSpec === "" ? await resolveVersion("latest", token) : await resolveVersion(versionSpec, token);
199
+ } catch (error) {
200
+ throw new SpacectlInstallError(`Failed to resolve version "${versionSpec}"`, "RESOLVE_VERSION_FAILED", error);
201
+ }
202
+ const cached = tc.find(TOOL_NAME, targetVersion, arch);
203
+ if (cached) {
204
+ const binPath = path.join(cached, binaryName);
205
+ core.info(`Using cached spacectl ${targetVersion} at ${cached}`);
206
+ return {
207
+ binPath,
208
+ version: targetVersion
209
+ };
210
+ }
211
+ const cachedDir = await downloadAndCache(targetVersion, token);
212
+ const binPath = path.join(cachedDir, binaryName);
213
+ await getInstalledVersion(binPath);
214
+ return {
215
+ binPath,
216
+ version: targetVersion
217
+ };
218
+ }
219
+
220
+ //#endregion
221
+ export { install as n, exec as r, SpacectlInstallError as t };
222
+ //# sourceMappingURL=spacectl-COQOkFHx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spacectl-COQOkFHx.mjs","names":["REPO_OWNER","REPO_NAME"],"sources":["../src/spacectl/exec.ts","../src/spacectl/platform.ts","../src/spacectl/version.ts","../src/spacectl/installer.ts"],"sourcesContent":["import * as core from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\n\nexport type ExecOptions = Omit<\n actionsExec.ExecOptions,\n \"listeners\" | \"ignoreReturnCode\" | \"silent\"\n>;\n\nexport type ExecResult = actionsExec.ExecOutput;\n\nexport async function exec(\n binPath: string,\n args: string[],\n options?: ExecOptions\n): Promise<ExecResult> {\n const execArgs = [...args, \"--output=json\"];\n\n let stdout = \"\";\n let stderr = \"\";\n\n const exitCode = await actionsExec.exec(binPath, execArgs, {\n ...options,\n ignoreReturnCode: true,\n silent: true,\n listeners: {\n stdout: (data: Buffer) => {\n stdout += data.toString();\n },\n stderr: (data: Buffer) => {\n stderr += data.toString();\n // Forward stderr to stdout so GitHub Actions can process workflow\n // commands like ::debug::. The space binary outputs these to stderr\n // when --output=json is used to keep stdout clean for JSON.\n process.stdout.write(data);\n },\n },\n });\n\n if (exitCode !== 0) {\n let errorMessage = `'${binPath} ${execArgs.join(\" \")}' failed with exit code ${exitCode}`;\n try {\n const errorJson = JSON.parse(stdout.trim());\n if (errorJson.message) {\n errorMessage = errorJson.message;\n }\n } catch {\n // stdout wasn't valid JSON, use default message\n }\n core.error(errorMessage);\n process.exit(exitCode);\n }\n\n return { exitCode, stdout, stderr };\n}\n","import * as os from \"node:os\";\n\nexport type Platform = \"darwin\" | \"linux\" | \"windows\";\nexport type Arch = \"amd64\" | \"arm64\";\n\nexport function getPlatform(): Platform {\n const platform = os.platform();\n switch (platform) {\n case \"darwin\":\n return \"darwin\";\n case \"linux\":\n return \"linux\";\n case \"win32\":\n return \"windows\";\n default:\n throw new Error(`Unsupported platform: ${platform}`);\n }\n}\n\nexport function getArch(): Arch {\n const arch = os.arch();\n switch (arch) {\n case \"arm64\":\n return \"arm64\";\n case \"x64\":\n return \"amd64\";\n default:\n return \"amd64\";\n }\n}\n\nexport function getBinaryName(): string {\n return getPlatform() === \"windows\" ? \"space.exe\" : \"space\";\n}\n","import * as core from \"@actions/core\";\nimport * as github from \"@actions/github\";\n\nconst REPO_OWNER = \"namespacelabs\";\nconst REPO_NAME = \"space\";\n\nexport function normalizeVersion(version: string): string {\n return version.trim().replace(/^v/, \"\");\n}\n\nexport async function getLatestVersion(token?: string): Promise<string> {\n const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || \"\");\n\n try {\n const { data: release } = await octokit.rest.repos.getLatestRelease({\n owner: REPO_OWNER,\n repo: REPO_NAME,\n });\n return normalizeVersion(release.tag_name);\n } catch (error) {\n core.debug(`Failed to get latest release: ${error}`);\n throw new Error(\n `Failed to resolve latest version. ` +\n `If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.`\n );\n }\n}\n\nexport async function getLatestDevVersion(token?: string): Promise<string> {\n const octokit = github.getOctokit(token || process.env.GITHUB_TOKEN || \"\");\n\n try {\n const iterator = octokit.paginate.iterator(octokit.rest.repos.listReleases, {\n owner: REPO_OWNER,\n repo: REPO_NAME,\n per_page: 100,\n });\n\n for await (const { data: releases } of iterator) {\n for (const release of releases) {\n if (release.tag_name.includes(\"-dev\")) {\n return normalizeVersion(release.tag_name);\n }\n }\n }\n\n throw new Error(\"No dev release found\");\n } catch (error) {\n core.debug(`Failed to get dev release: ${error}`);\n throw new Error(\n `Failed to resolve dev version. ` +\n `If hitting rate limits, provide a GitHub token via options.githubToken or GITHUB_TOKEN env var.`\n );\n }\n}\n\nexport async function resolveVersion(versionSpec: string, token?: string): Promise<string> {\n const spec = versionSpec.trim().toLowerCase();\n\n if (spec === \"\" || spec === \"latest\") {\n return getLatestVersion(token);\n }\n\n if (spec === \"dev\") {\n return getLatestDevVersion(token);\n }\n\n return normalizeVersion(versionSpec);\n}\n","import * as path from \"node:path\";\nimport * as core from \"@actions/core\";\nimport * as io from \"@actions/io\";\nimport * as tc from \"@actions/tool-cache\";\n\nimport { exec } from \"./exec\";\nimport { getPlatform, getArch, getBinaryName } from \"./platform\";\nimport { resolveVersion, normalizeVersion } from \"./version\";\n\nconst TOOL_NAME = \"space\";\nconst REPO_OWNER = \"namespacelabs\";\nconst REPO_NAME = \"space\";\n\nexport interface InstallOptions {\n version?: string;\n githubToken?: string;\n}\n\nexport interface InstallResult {\n binPath: string;\n version: string;\n}\n\nexport type SpacectlInstallErrorCode =\n | \"UNSUPPORTED_PLATFORM\"\n | \"RESOLVE_VERSION_FAILED\"\n | \"DOWNLOAD_FAILED\"\n | \"EXEC_FAILED\";\n\nexport class SpacectlInstallError extends Error {\n readonly code: SpacectlInstallErrorCode;\n readonly cause?: unknown;\n\n constructor(message: string, code: SpacectlInstallErrorCode, cause?: unknown) {\n super(message);\n this.name = \"SpacectlInstallError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\nasync function findExistingBinary(): Promise<string | undefined> {\n const binaryName = getBinaryName();\n\n const powertoysDir = process.env.NSC_POWERTOYS_DIR;\n if (powertoysDir) {\n const powertoysPath = path.join(powertoysDir, binaryName);\n try {\n await io.which(powertoysPath, true);\n core.debug(`Found existing binary in powertoys: ${powertoysPath}`);\n return powertoysPath;\n } catch {\n core.debug(`Binary not found in powertoys dir: ${powertoysPath}`);\n }\n }\n\n try {\n const systemPath = await io.which(TOOL_NAME, true);\n core.debug(`Found existing binary on PATH: ${systemPath}`);\n return systemPath;\n } catch {\n core.debug(\"Binary not found on PATH\");\n }\n\n return undefined;\n}\n\nasync function getInstalledVersion(binPath: string): Promise<string> {\n const result = await exec(binPath, [\"version\"]);\n\n try {\n const parsed = JSON.parse(result.stdout.trim());\n return normalizeVersion(parsed.version);\n } catch (error) {\n core.debug(`Failed to parse version output: ${error}`);\n throw new SpacectlInstallError(`Failed to validate binary at ${binPath}`, \"EXEC_FAILED\", error);\n }\n}\n\nfunction getDownloadUrl(version: string): string {\n const platform = getPlatform();\n const arch = getArch();\n const filename = `${TOOL_NAME}_${version}_${platform}_${arch}.tar.gz`;\n return `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/v${version}/${filename}`;\n}\n\nasync function downloadAndCache(version: string, token?: string): Promise<string> {\n const platform = getPlatform();\n const arch = getArch();\n const url = getDownloadUrl(version);\n\n core.info(`Downloading spacectl ${version} from ${url}`);\n\n let archivePath: string;\n try {\n const headers: Record<string, string> = {};\n if (token) {\n headers[\"Authorization\"] = `token ${token}`;\n }\n archivePath = await tc.downloadTool(url, undefined, undefined, headers);\n } catch (error) {\n throw new SpacectlInstallError(\n `Failed to download spacectl ${version} for ${platform}/${arch}`,\n \"DOWNLOAD_FAILED\",\n error\n );\n }\n\n const extractedPath = await tc.extractTar(archivePath);\n const cachedPath = await tc.cacheDir(extractedPath, TOOL_NAME, version, arch);\n\n core.info(`Cached spacectl ${version} to ${cachedPath}`);\n return cachedPath;\n}\n\nexport async function install(options: InstallOptions = {}): Promise<InstallResult> {\n const versionSpec = options.version ?? \"\";\n const token = options.githubToken ?? process.env.GITHUB_TOKEN;\n\n try {\n getPlatform();\n } catch (error) {\n throw new SpacectlInstallError(\n `Unsupported platform: ${process.platform}`,\n \"UNSUPPORTED_PLATFORM\",\n error\n );\n }\n\n const arch = getArch();\n const binaryName = getBinaryName();\n\n if (versionSpec === \"\") {\n const existingPath = await findExistingBinary();\n if (existingPath) {\n const version = await getInstalledVersion(existingPath);\n core.info(`Using existing spacectl ${version} at ${existingPath}`);\n return {\n binPath: existingPath,\n version,\n };\n }\n core.info(\"No existing spacectl found, downloading latest version\");\n }\n\n let targetVersion: string;\n try {\n targetVersion =\n versionSpec === \"\"\n ? await resolveVersion(\"latest\", token)\n : await resolveVersion(versionSpec, token);\n } catch (error) {\n throw new SpacectlInstallError(\n `Failed to resolve version \"${versionSpec}\"`,\n \"RESOLVE_VERSION_FAILED\",\n error\n );\n }\n\n const cached = tc.find(TOOL_NAME, targetVersion, arch);\n if (cached) {\n const binPath = path.join(cached, binaryName);\n core.info(`Using cached spacectl ${targetVersion} at ${cached}`);\n return {\n binPath,\n version: targetVersion,\n };\n }\n\n const cachedDir = await downloadAndCache(targetVersion, token);\n const binPath = path.join(cachedDir, binaryName);\n\n await getInstalledVersion(binPath);\n\n return {\n binPath,\n version: targetVersion,\n };\n}\n"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,KAAK,mBAAmB,QAAQ,MAAM,aAAa;AACxD,QAAO;;AAGT,eAAsB,QAAQ,UAA0B,EAAE,EAA0B;CAClF,MAAM,cAAc,QAAQ,WAAW;CACvC,MAAM,QAAQ,QAAQ,eAAe,QAAQ,IAAI;AAEjD,KAAI;AACF,eAAa;UACN,OAAO;AACd,QAAM,IAAI,qBACR,yBAAyB,QAAQ,YACjC,wBACA,MACD;;CAGH,MAAM,OAAO,SAAS;CACtB,MAAM,aAAa,eAAe;AAElC,KAAI,gBAAgB,IAAI;EACtB,MAAM,eAAe,MAAM,oBAAoB;AAC/C,MAAI,cAAc;GAChB,MAAM,UAAU,MAAM,oBAAoB,aAAa;AACvD,QAAK,KAAK,2BAA2B,QAAQ,MAAM,eAAe;AAClE,UAAO;IACL,SAAS;IACT;IACD;;AAEH,OAAK,KAAK,yDAAyD;;CAGrE,IAAI;AACJ,KAAI;AACF,kBACE,gBAAgB,KACZ,MAAM,eAAe,UAAU,MAAM,GACrC,MAAM,eAAe,aAAa,MAAM;UACvC,OAAO;AACd,QAAM,IAAI,qBACR,8BAA8B,YAAY,IAC1C,0BACA,MACD;;CAGH,MAAM,SAAS,GAAG,KAAK,WAAW,eAAe,KAAK;AACtD,KAAI,QAAQ;EACV,MAAM,UAAU,KAAK,KAAK,QAAQ,WAAW;AAC7C,OAAK,KAAK,yBAAyB,cAAc,MAAM,SAAS;AAChE,SAAO;GACL;GACA,SAAS;GACV;;CAGH,MAAM,YAAY,MAAM,iBAAiB,eAAe,MAAM;CAC9D,MAAM,UAAU,KAAK,KAAK,WAAW,WAAW;AAEhD,OAAM,oBAAoB,QAAQ;AAElC,QAAO;EACL;EACA,SAAS;EACV"}
@@ -0,0 +1,5 @@
1
+ const require_spacectl = require('./spacectl-6udimwjI.cjs');
2
+
3
+ exports.SpacectlInstallError = require_spacectl.SpacectlInstallError;
4
+ exports.exec = require_spacectl.exec;
5
+ exports.install = require_spacectl.install;
@@ -0,0 +1,2 @@
1
+ import { a as ExecOptions, i as install, n as InstallResult, o as ExecResult, r as SpacectlInstallError, s as exec, t as InstallOptions } from "./index-DJzkZaGq.cjs";
2
+ export { ExecOptions, ExecResult, InstallOptions, InstallResult, SpacectlInstallError, exec, install };
@@ -0,0 +1,2 @@
1
+ import { a as ExecOptions, i as install, n as InstallResult, o as ExecResult, r as SpacectlInstallError, s as exec, t as InstallOptions } from "./index-C6FXIu0Q.mjs";
2
+ export { ExecOptions, ExecResult, InstallOptions, InstallResult, SpacectlInstallError, exec, install };
@@ -0,0 +1,3 @@
1
+ import { n as install, r as exec, t as SpacectlInstallError } from "./spacectl-COQOkFHx.mjs";
2
+
3
+ export { SpacectlInstallError, exec, install };
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@namespacelabs/actions-toolkit",
3
+ "version": "0.1.0",
4
+ "description": "GitHub Actions toolkit for Namespace",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/namespacelabs/nscloud-actions-toolkit.git"
10
+ },
11
+ "engines": {
12
+ "node": ">=20"
13
+ },
14
+ "packageManager": "pnpm@10.6.2",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.cts",
21
+ "exports": {
22
+ ".": {
23
+ "import": {
24
+ "types": "./dist/index.d.mts",
25
+ "default": "./dist/index.mjs"
26
+ },
27
+ "require": {
28
+ "types": "./dist/index.d.cts",
29
+ "default": "./dist/index.cjs"
30
+ }
31
+ },
32
+ "./spacectl": {
33
+ "import": {
34
+ "types": "./dist/spacectl.d.mts",
35
+ "default": "./dist/spacectl.mjs"
36
+ },
37
+ "require": {
38
+ "types": "./dist/spacectl.d.cts",
39
+ "default": "./dist/spacectl.cjs"
40
+ }
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
44
+ "scripts": {
45
+ "build": "tsdown",
46
+ "clean": "rm -rf dist",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint src",
49
+ "lint:fix": "eslint src --fix",
50
+ "format": "prettier --write \"src/**/*.ts\"",
51
+ "format:check": "prettier --check \"src/**/*.ts\"",
52
+ "test": "vitest",
53
+ "test:run": "vitest run"
54
+ },
55
+ "dependencies": {
56
+ "@actions/core": "^1.11.1",
57
+ "@actions/exec": "^1.1.1",
58
+ "@actions/github": "^6.0.1",
59
+ "@actions/io": "^1.1.3",
60
+ "@actions/tool-cache": "^2.0.2"
61
+ },
62
+ "devDependencies": {
63
+ "@eslint/js": "^9.39.2",
64
+ "@types/node": "^22.15.21",
65
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
66
+ "@typescript-eslint/parser": "^8.32.1",
67
+ "eslint": "^9.27.0",
68
+ "prettier": "^3.5.3",
69
+ "tsdown": "^0.20.1",
70
+ "typescript": "^5.8.3",
71
+ "typescript-eslint": "^8.54.0",
72
+ "vitest": "^3.1.4"
73
+ }
74
+ }