Skip to content

Commit 9e3f6df

Browse files
committed
fix: automatically parse documentation urls
1 parent 4512481 commit 9e3f6df

52 files changed

Lines changed: 42 additions & 51 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "1.1.0",
3+
"version": "1.1.2",
44
"description": "Default plugin for Codify - provides 50+ declarative resources for managing development tools and system configuration across macOS and Linux",
55
"main": "dist/index.js",
66
"scripts": {

scripts/deploy.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
import * as cp from 'node:child_process';
2+
import { readdirSync } from 'node:fs';
23
import path from 'node:path';
34
import * as url from 'node:url';
45
import { createRequire } from 'node:module';
56
import 'dotenv/config'
67
import { createClient } from '@supabase/supabase-js';
78

9+
const DOCS_BASE_URL = 'https://codifycli.com';
10+
const DOCS_DIR = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..', 'docs', 'resources', '(resources)');
11+
12+
function buildDocUrlMap(dir: string, urlPrefix: string, knownTypes?: Set<string>): Map<string, string> {
13+
const map = new Map<string, string>();
14+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
15+
if (entry.isDirectory()) {
16+
buildDocUrlMap(path.join(dir, entry.name), `${urlPrefix}/${entry.name}`, knownTypes)
17+
.forEach((v, k) => map.set(k, v));
18+
} else if (entry.name.endsWith('.mdx')) {
19+
const type = entry.name.replace(/\.mdx$/, '');
20+
if (knownTypes && !knownTypes.has(type)) {
21+
throw new Error(`Doc file "${entry.name}" does not match any known resource type. Check the filename.`);
22+
}
23+
map.set(type, `${DOCS_BASE_URL}${urlPrefix}/${type}`);
24+
}
25+
}
26+
return map;
27+
}
28+
29+
const docUrlMap = buildDocUrlMap(DOCS_DIR, '/docs/resources');
30+
831
const require = createRequire(import.meta.url);
932

1033
// This should run the build
@@ -89,6 +112,9 @@ async function uploadResources(prerelease: boolean) {
89112

90113
const resources = CodifySchema.items.oneOf;
91114

115+
const knownTypes = new Set<string>(resources.map((r: any) => r.properties.type.const));
116+
buildDocUrlMap(DOCS_DIR, '/docs/resources', knownTypes);
117+
92118
for (const resource of resources) {
93119
const type = resource.properties.type.const;
94120
const metadata = metadataByType.get(type);
@@ -100,7 +126,7 @@ async function uploadResources(prerelease: boolean) {
100126
plugin_name: pluginName,
101127
prerelease,
102128
schema: JSON.stringify(resource),
103-
documentation_url: resource.$comment,
129+
documentation_url: docUrlMap.get(type) ?? null,
104130
allow_multiple: metadata?.allowMultiple ?? false,
105131
os: metadata?.operatingSystems ?? [],
106132
default_config: metadata?.defaultConfig ? JSON.stringify(metadata.defaultConfig) : null,

src/resources/android/android-studio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const schema = z.object({
2121
'The directory to install Android Studios into. Defaults to /Applications on macOS, /opt on Linux'
2222
)
2323
.optional(),
24-
}).meta({ $comment: 'https://codifycli.com/docs/resources/android-studio' })
24+
})
2525

2626
export type AndroidStudioConfig = z.infer<typeof schema>;
2727

src/resources/apt/apt-schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "https://www.codifycli.com/apt.json",
4-
"$comment": "https://codifycli.com/docs/resources/apt/",
54
"title": "Apt resource",
65
"description": "Manage apt packages on Debian-based systems.",
76
"type": "object",

src/resources/asdf/asdf-install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const schema = z.object({
2727
.string()
2828
.describe('The directory to run the install command')
2929
.optional(),
30-
}).meta({ $comment: 'https://codifycli.com/docs/resources/asdf/asdf-install' })
30+
})
3131
.describe('Install specific version of tools using asdf.');
3232

3333
export type AsdfInstallConfig = z.infer<typeof schema>;

src/resources/asdf/asdf-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const schema = z
2323
.string()
2424
.describe('The gitUrl of the plugin')
2525
.optional()
26-
}).meta({ $comment: 'https://codifycli.com/docs/resources/asdf/asdf-plugin' })
26+
})
2727
.describe('Asdf plugin resource for installing asdf plugins.');
2828
export type AsdfPluginConfig = z.infer<typeof schema>;
2929

src/resources/asdf/asdf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const schema = z.object({
1313
'Asdf plugins to install. See: https://github.com/asdf-community for a full list'
1414
)
1515
.optional()
16-
}).meta({ $comment: 'https://codifycli.com/docs/resources/asdf/asdf' })
16+
})
1717
.describe('Asdf resource for installing asdf, a tool version manager');
1818

1919
export type AsdfConfig = z.infer<typeof schema>

src/resources/aws-cli/cli/aws-cli-schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "https://www.codifycli.com/aws-cli.json",
4-
"$comment": "https://codifycli.com/docs/resources/aws-cli/",
54
"title": "Aws-CLI resource",
65
"type": "object",
76
"description": "Installs aws-cli.",

src/resources/aws-cli/profile/aws-profile-schema.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema",
33
"$id": "https://www.codifycli.com/aws-profile.json",
4-
"$comment": "https://codifycli.com/docs/resources/aws-profile/",
54
"title": "Aws-CLI configure resource",
65
"type": "object",
76
"description": "Configures AWS profiles.",

0 commit comments

Comments
 (0)