Skip to content

Commit 695fb40

Browse files
committed
feat: Added minCliVersion support
1 parent 040dd0c commit 695fb40

5 files changed

Lines changed: 60 additions & 30 deletions

File tree

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "default",
3-
"version": "1.1.0-beta6",
3+
"version": "1.1.0-beta.1",
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": {
@@ -41,8 +41,8 @@
4141
"license": "ISC",
4242
"type": "module",
4343
"dependencies": {
44-
"@codifycli/plugin-core": "1.1.0-beta16",
45-
"@codifycli/schemas": "1.1.0-beta5",
44+
"@codifycli/plugin-core": "1.1.0-beta17",
45+
"@codifycli/schemas": "1.1.0-beta6",
4646
"ajv": "^8.18.0",
4747
"ajv-formats": "^2.1.1",
4848
"chalk": "^5.3.0",

scripts/build.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const initializeResult = await sendMessageAndAwaitResponse(plugin, {
5959
data: {}
6060
})
6161

62-
const { resourceDefinitions } = initializeResult;
62+
const { resourceDefinitions, minSupportedCliVersion } = initializeResult;
6363
const resourceTypes = resourceDefinitions.map((i) => i.type);
6464

6565
const schemasMap = new Map<string, JSONSchema>()
@@ -125,6 +125,10 @@ const metadataOutputPath = path.resolve(distFolder, 'metadata.json');
125125
fs.writeFileSync(metadataOutputPath, JSON.stringify(metadataList, null, 2));
126126
console.log('Successfully wrote metadata to ./dist/metadata.json')
127127

128+
const pluginManifestPath = path.resolve(distFolder, 'plugin-manifest.json');
129+
fs.writeFileSync(pluginManifestPath, JSON.stringify({ minSupportedCliVersion: minSupportedCliVersion ?? null }, null, 2));
130+
console.log('Successfully wrote plugin manifest to ./dist/plugin-manifest.json')
131+
128132

129133
plugin.kill(9);
130134
process.exit(0);

scripts/deploy.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import { createClient } from '@supabase/supabase-js';
77

88
const require = createRequire(import.meta.url);
99

10-
1110
// This should run the build
1211
cp.spawnSync('source ~/.zshrc; npm run build', { shell: 'zsh', stdio: 'inherit' });
1312

13+
const PluginManifest: { minSupportedCliVersion: string | null } = require('../dist/plugin-manifest.json');
14+
1415
const version = process.env.npm_package_version;
1516
if (!version) {
1617
throw new Error('Unable to find version');
@@ -31,6 +32,35 @@ console.log(`Uploading plugin ${name}, version ${version} to cloudflare!`)
3132
const outputFilePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..', 'dist', 'index.js')
3233
cp.spawnSync(`source ~/.zshrc; npx wrangler r2 object put plugins/${name}/${version}/index.js --file=${outputFilePath} --remote`, { shell: 'zsh', stdio: 'inherit' });
3334

35+
const client = createClient(
36+
process.env.SUPABASE_URL!,
37+
process.env.SUPABASE_SERVICE_ROLE_KEY!,
38+
);
39+
40+
console.log('Adding default plugin');
41+
const defaultPlugin = await client.from('registry_plugins').upsert({
42+
name: 'default',
43+
display_name: 'Default Plugin',
44+
homepage: 'https://codifycli.com',
45+
repository_url: 'https://github.com/codifycli/default-plugin',
46+
license: 'ISC',
47+
}, { onConflict: 'name' })
48+
.select()
49+
.throwOnError();
50+
51+
const { id: pluginId, name: pluginName } = defaultPlugin.data![0];
52+
53+
console.log('Upserting plugin version');
54+
const versionRow = await client.from('registry_plugin_versions').upsert({
55+
plugin_id: pluginId,
56+
version,
57+
bundle_url: `https://plugins.codifycli.com/${name}/${version}/index.js`,
58+
min_cli_version: PluginManifest.minSupportedCliVersion,
59+
published_at: new Date().toISOString(),
60+
}, { onConflict: 'plugin_id,version' })
61+
.select()
62+
.throwOnError();
63+
3464
if (!isBeta) {
3565
await uploadResources();
3666

@@ -45,19 +75,13 @@ async function uploadResources() {
4575

4676
const metadataByType = new Map(Metadata.map((m) => [m.type, m]));
4777

48-
const client = createClient(
49-
process.env.SUPABASE_URL!,
50-
process.env.SUPABASE_SERVICE_ROLE_KEY!,
51-
);
78+
const { id: versionId } = versionRow.data![0];
5279

53-
console.log('Adding default plugin');
54-
const defaultPlugin = await client.from('registry_plugins').upsert({
55-
name: 'default',
56-
}, { onConflict: 'name' })
57-
.select()
80+
console.log('Updating latest version pointer');
81+
await client.from('registry_plugins')
82+
.update({ latest_version: version, latest_version_id: versionId })
83+
.eq('id', pluginId)
5884
.throwOnError();
59-
60-
const { id: pluginId, name: pluginName } = defaultPlugin.data![0];
6185
const resources = CodifySchema.items.oneOf;
6286

6387
for (const resource of resources) {

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Plugin, runPlugin } from '@codifycli/plugin-core';
2-
32
import { AndroidStudioResource } from './resources/android/android-studio.js';
43
import { AptResource } from './resources/apt/apt.js';
54
import { AsdfResource } from './resources/asdf/asdf.js';
@@ -51,6 +50,8 @@ import { VscodeResource } from './resources/vscode/vscode.js';
5150
import { XcodeToolsResource } from './resources/xcode-tools/xcode-tools.js';
5251
import { YumResource } from './resources/yum/yum.js';
5352

53+
export const MIN_SUPPORTED_CLI_VERSION: string | undefined = '1.1.0';
54+
5455
runPlugin(Plugin.create(
5556
'default',
5657
[
@@ -104,5 +105,6 @@ runPlugin(Plugin.create(
104105
new SyncthingDeviceResource(),
105106
new SyncthingFolderResource(),
106107
new RbenvResource(),
107-
])
108-
)
108+
],
109+
{ minSupportedCliVersion: MIN_SUPPORTED_CLI_VERSION }
110+
))

0 commit comments

Comments
 (0)