Skip to content

Commit ad02cd1

Browse files
authored
fix: Audit 02/26 (#41)
1 parent 3f0dc32 commit ad02cd1

3 files changed

Lines changed: 50 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.6.3
2+
3+
- Added moon v2 configuration support.
4+
15
# 0.6.2
26

37
- Revert proto v0.55 compatibility.

helpers.ts

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export function isCacheEnabled() {
5656
}
5757

5858
export function isUsingMoon() {
59-
return !!core.getInput('moon-version') || fs.existsSync(path.join(getWorkspaceRoot(), '.moon'));
59+
return (
60+
!!core.getInput('moon-version') ||
61+
fs.existsSync(path.join(getWorkspaceRoot(), '.moon')) ||
62+
fs.existsSync(path.join(getWorkspaceRoot(), '.config', 'moon'))
63+
);
6064
}
6165

6266
export function shouldInstallMoon() {
@@ -106,14 +110,22 @@ export async function getToolchainCacheKey() {
106110
if (isUsingMoon()) {
107111
const root = core.getInput('workspace-root');
108112

113+
files.push(
114+
// v1
115+
'.moon/toolchain.yml',
116+
// v2
117+
'.moon/toolchains.yml',
118+
'.config/moon/toolchains.yml',
119+
);
120+
109121
if (root) {
110-
files.push(
111-
path.join(root, '.prototools'),
112-
path.join(root, '.protolock'),
113-
path.join(root, '.moon/toolchain.yml'),
114-
);
115-
} else {
116-
files.push('.moon/toolchain.yml');
122+
const moreFiles: string[] = [];
123+
124+
for (const file of files) {
125+
moreFiles.push(path.join(root, file));
126+
}
127+
128+
files.push(...moreFiles);
117129
}
118130
}
119131

@@ -156,17 +168,27 @@ export function getProtoVersion(): string {
156168
}
157169

158170
if (isUsingMoon()) {
159-
const toolchainPath = path.join(getWorkspaceRoot(), '.moon/toolchain.yml');
160-
161-
if (fs.existsSync(toolchainPath)) {
162-
const toolchain = yaml.parse(fs.readFileSync(toolchainPath, 'utf8')) as {
163-
proto?: { version?: string };
164-
};
165-
const protoVersion = toolchain.proto?.version;
166-
167-
// Only fully-qualified is allowed
168-
if (protoVersion && typeof protoVersion === 'string' && protoVersion.split('.').length >= 3) {
169-
return protoVersion;
171+
for (const file of [
172+
'.moon/toolchain.yml',
173+
'.moon/toolchains.yml',
174+
'.config/moon/toolchains.yml',
175+
]) {
176+
const toolchainPath = path.join(getWorkspaceRoot(), file);
177+
178+
if (fs.existsSync(toolchainPath)) {
179+
const toolchain = yaml.parse(fs.readFileSync(toolchainPath, 'utf8')) as {
180+
proto?: { version?: string };
181+
};
182+
const protoVersion = toolchain?.proto?.version;
183+
184+
// Only fully-qualified is allowed
185+
if (
186+
protoVersion &&
187+
typeof protoVersion === 'string' &&
188+
protoVersion.split('.').length >= 3
189+
) {
190+
return protoVersion;
191+
}
170192
}
171193
}
172194
}
@@ -195,7 +217,10 @@ export async function installBin(bin: string) {
195217

196218
core.info('Downloading installation script');
197219

198-
const script = await tc.downloadTool(`https://raw.githubusercontent.com/moonrepo/moon/refs/heads/master/website/static/install/${scriptName}`, scriptPath);
220+
const script = await tc.downloadTool(
221+
`https://raw.githubusercontent.com/moonrepo/moon/refs/heads/master/website/static/install/${scriptName}`,
222+
scriptPath,
223+
);
199224

200225
// eslint-disable-next-line no-magic-numbers
201226
await fs.promises.chmod(script, 0o755);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moonrepo/setup-toolchain",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "A GitHub action to setup and cache the proto and moon toolchains.",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)