freestyle-sync 0.1.0 → 0.1.1

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.
@@ -13,7 +13,6 @@ import { sshAuthPlugin } from "@freestyle-sync/auth-ssh";
13
13
  import { yarnAuthPlugin } from "@freestyle-sync/auth-yarn";
14
14
  import { nodeNpmPlugin } from "@freestyle-sync/node-npm";
15
15
  import { shellHistoryPlugin } from "@freestyle-sync/shell-history";
16
- import { vscodePlugin } from "@freestyle-sync/vscode";
17
16
  import { defineConfig } from "./src/plugin-api.ts";
18
17
 
19
18
  export default defineConfig({
@@ -33,6 +32,5 @@ export default defineConfig({
33
32
  codexAgentPlugin(),
34
33
  copilotAgentPlugin(),
35
34
  shellHistoryPlugin(),
36
- // vscodePlugin(),
37
35
  ],
38
36
  });
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "freestyle-sync",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "src/main.ts",
6
6
  "workspaces": [
7
7
  "plugins/*"
8
8
  ],
9
9
  "bin": {
10
- "pushvm": "src/main.ts"
10
+ "freestyle-sync": "src/main.ts"
11
11
  },
12
12
  "engines": {
13
13
  "node": ">=24"
package/src/main.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import "dotenv/config"
3
3
  import { createHash } from "node:crypto";
4
- import { createReadStream } from "node:fs";
4
+ import { createReadStream, realpathSync } from "node:fs";
5
5
  import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
6
6
  import { tmpdir } from "node:os";
7
7
  import path from "node:path";
8
+ import { fileURLToPath, pathToFileURL } from "node:url";
8
9
  import { execFile, spawn } from "node:child_process";
9
10
  import { promisify } from "node:util";
10
11
  import { freestyle } from "freestyle";
11
- import config from "../freestyle-sync.config.ts";
12
- import type { CliOptions, ContextCandidate, PushvmPluginUtils, RemoteVm } from "./plugin-api.ts";
12
+ import type { CliOptions, ContextCandidate, PushvmConfig, PushvmPluginUtils, RemoteVm } from "./plugin-api.ts";
13
13
  export * from "./plugin-api.ts";
14
14
 
15
15
  const execFileAsync = promisify(execFile);
@@ -17,6 +17,7 @@ const execFileAsync = promisify(execFile);
17
17
  const CACHE_VERSION = 1;
18
18
  const PLUGIN_PREFERENCES_VERSION = 1;
19
19
  const ARCHIVE_CHUNK_CHARS = 1024 * 1024;
20
+ let config: PushvmConfig = { plugins: [] };
20
21
  let plugins = config.plugins;
21
22
  const pluginUtils: PushvmPluginUtils = {
22
23
  checkedExec,
@@ -89,13 +90,17 @@ class Progress {
89
90
  }
90
91
  }
91
92
 
92
- main().catch((error) => {
93
- console.error(`vmpush: ${error instanceof Error ? error.message : String(error)}`);
94
- process.exitCode = 1;
95
- });
93
+ if (isDirectCliExecution()) {
94
+ main().catch((error) => {
95
+ console.error(`vmpush: ${error instanceof Error ? error.message : String(error)}`);
96
+ process.exitCode = 1;
97
+ });
98
+ }
96
99
 
97
100
  async function main() {
98
101
  const options = await parseArgs(process.argv.slice(2));
102
+ config = await loadConfig(options.projectRoot);
103
+ plugins = config.plugins;
99
104
  const pluginPreferences = await updatePluginPreferences(options);
100
105
  plugins = activePlugins(pluginPreferences, options);
101
106
  if (options.listPlugins) {
@@ -212,6 +217,70 @@ async function main() {
212
217
  }
213
218
  }
214
219
 
220
+ function isDirectCliExecution() {
221
+ if (!process.argv[1]) return false;
222
+ try {
223
+ return realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
224
+ } catch {
225
+ return path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
226
+ }
227
+ }
228
+
229
+ async function loadConfig(projectRoot: string): Promise<PushvmConfig> {
230
+ const configPath = path.join(projectRoot, "freestyle-sync.config.ts");
231
+ if (!(await exists(configPath))) {
232
+ await writeFile(configPath, renderDefaultConfig(), "utf8");
233
+ console.log(`Created ${path.relative(process.cwd(), configPath) || path.basename(configPath)}`);
234
+ }
235
+
236
+ const imported = await import(pathToFileURL(configPath).href);
237
+ const loaded = imported.default as PushvmConfig | undefined;
238
+ if (!loaded || !Array.isArray(loaded.plugins)) {
239
+ throw new Error(`${configPath} must export default defineConfig({ plugins: [...] })`);
240
+ }
241
+ return loaded;
242
+ }
243
+
244
+ function renderDefaultConfig() {
245
+ return `import { claudeAgentPlugin } from "@freestyle-sync/agent-claude";
246
+ import { codexAgentPlugin } from "@freestyle-sync/agent-codex";
247
+ import { copilotAgentPlugin } from "@freestyle-sync/agent-copilot";
248
+ import { awsAuthPlugin } from "@freestyle-sync/auth-aws";
249
+ import { azureAuthPlugin } from "@freestyle-sync/auth-azure";
250
+ import { dockerAuthPlugin } from "@freestyle-sync/auth-docker";
251
+ import { envAuthPlugin } from "@freestyle-sync/auth-env";
252
+ import { gcloudAuthPlugin } from "@freestyle-sync/auth-gcloud";
253
+ import { gitAuthPlugin } from "@freestyle-sync/auth-git";
254
+ import { githubCliAuthPlugin } from "@freestyle-sync/auth-github-cli";
255
+ import { npmAuthPlugin } from "@freestyle-sync/auth-npm";
256
+ import { sshAuthPlugin } from "@freestyle-sync/auth-ssh";
257
+ import { yarnAuthPlugin } from "@freestyle-sync/auth-yarn";
258
+ import { nodeNpmPlugin } from "@freestyle-sync/node-npm";
259
+ import { shellHistoryPlugin } from "@freestyle-sync/shell-history";
260
+ import { defineConfig } from "freestyle-sync";
261
+
262
+ export default defineConfig({
263
+ plugins: [
264
+ envAuthPlugin(),
265
+ gitAuthPlugin(),
266
+ sshAuthPlugin(),
267
+ githubCliAuthPlugin(),
268
+ npmAuthPlugin(),
269
+ yarnAuthPlugin(),
270
+ dockerAuthPlugin(),
271
+ awsAuthPlugin(),
272
+ azureAuthPlugin(),
273
+ gcloudAuthPlugin(),
274
+ nodeNpmPlugin(),
275
+ claudeAgentPlugin(),
276
+ codexAgentPlugin(),
277
+ copilotAgentPlugin(),
278
+ shellHistoryPlugin(),
279
+ ],
280
+ });
281
+ `;
282
+ }
283
+
215
284
  async function parseArgs(args: string[]): Promise<CliOptions> {
216
285
  const options: CliOptions = {
217
286
  projectRoot: process.cwd(),