diff --git a/.changeset/gentle-goats-poke.md b/.changeset/gentle-goats-poke.md new file mode 100644 index 000000000..88a8476d1 --- /dev/null +++ b/.changeset/gentle-goats-poke.md @@ -0,0 +1,7 @@ +--- +'@openfn/engine-multi': minor +'@openfn/runtime': minor +'@openfn/cli': minor +--- + +Update default repo directory to be relative to homedir diff --git a/.changeset/short-rules-switch.md b/.changeset/short-rules-switch.md new file mode 100644 index 000000000..920f709d2 --- /dev/null +++ b/.changeset/short-rules-switch.md @@ -0,0 +1,5 @@ +--- +'@openfn/cli': patch +--- + +apollo: update staging url diff --git a/packages/cli/src/apollo/util.ts b/packages/cli/src/apollo/util.ts index 5a9c2b599..a7a014810 100644 --- a/packages/cli/src/apollo/util.ts +++ b/packages/cli/src/apollo/util.ts @@ -3,8 +3,7 @@ import { ApolloOptions } from './command'; export const PRODUCTION_URL = 'https://apollo.openfn.org'; -//export const STAGING_URL = 'https://apollo-staging.openfn.org'; -export const STAGING_URL = 'http://34.95.82.109'; // use direct ip for now +export const STAGING_URL = 'https://apollo-staging.openfn.org'; export const LOCAL_URL = 'http://localhost:3000'; diff --git a/packages/cli/src/constants.ts b/packages/cli/src/constants.ts deleted file mode 100644 index 7c7ffa98f..000000000 --- a/packages/cli/src/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const DEFAULT_REPO_DIR = '/tmp/openfn/repo'; diff --git a/packages/cli/src/options.ts b/packages/cli/src/options.ts index 4f214c02f..ae8bd3f82 100644 --- a/packages/cli/src/options.ts +++ b/packages/cli/src/options.ts @@ -2,13 +2,13 @@ import nodePath from 'node:path'; import yargs from 'yargs'; import type { CommandList } from './commands'; -import { DEFAULT_REPO_DIR } from './constants'; import { expandAdaptors as doExpandAdaptors, ensureLogOpts, LogLevel, } from './util'; import { existsSync } from 'node:fs'; +import { defaultRepoPath } from '@openfn/runtime'; // Central type definition for the main options // This represents the types coming out of yargs, @@ -490,20 +490,8 @@ export const repoDir: CLIOption = { name: 'repo-dir', yargs: () => ({ description: 'Provide a path to the repo root dir', - default: process.env.OPENFN_REPO_DIR || DEFAULT_REPO_DIR, + default: process.env.OPENFN_REPO_DIR || defaultRepoPath, }), - ensure: (opts) => { - if (opts.repoDir === DEFAULT_REPO_DIR) { - // Note that we don't use the logger here - it's not been created yet - console.warn( - 'WARNING: no repo module dir found! Using the default (/tmp/repo)' - ); - console.warn( - 'You should set OPENFN_REPO_DIR or pass --repoDir=some/path in to the CLI' - ); - console.log(); - } - }, }; export const start: CLIOption = { diff --git a/packages/cli/test/options/repo.test.ts b/packages/cli/test/options/repo.test.ts index abe51675a..bffb8deb9 100644 --- a/packages/cli/test/options/repo.test.ts +++ b/packages/cli/test/options/repo.test.ts @@ -4,7 +4,7 @@ import yargs from 'yargs'; import { repo } from '../../src/repo/command'; import type { Opts } from '../../src/options'; -import { DEFAULT_REPO_DIR } from '../../src/constants'; +import { defaultRepoPath } from '@openfn/runtime'; // Build the repo command and test the options it returns // Note that this will re-parse the command each time, so env vars will be re-calculated @@ -17,7 +17,7 @@ test('repoDir: use the built-in default if no env var', (t) => { const options = parse('repo'); - t.is(options.repoDir, DEFAULT_REPO_DIR); + t.is(options.repoDir, defaultRepoPath); process.env.OPENFN_REPO_DIR = dir; }); diff --git a/packages/engine-multi/src/api.ts b/packages/engine-multi/src/api.ts index ef537832f..29450b16a 100644 --- a/packages/engine-multi/src/api.ts +++ b/packages/engine-multi/src/api.ts @@ -1,6 +1,8 @@ // Creates the public/external API to the runtime // Basically a thin wrapper, with validation, around the engine +import path from 'node:path'; +import os from 'node:os'; import createLogger from '@openfn/logger'; import whitelist from './whitelist'; @@ -23,7 +25,7 @@ export type LazyResolvers = { export type APIOptions = Partial>; -const DEFAULT_REPO_DIR = '/tmp/openfn/worker/repo'; +const DEFAULT_REPO_DIR = path.join(os.homedir(), '.openfn/worker/repo'); const DEFAULT_MEMORY_LIMIT = 500; @@ -38,7 +40,6 @@ const createAPI = async function ( if (!repoDir) { repoDir = DEFAULT_REPO_DIR; - logger.warn('Using default repo directory: ', DEFAULT_REPO_DIR); } logger.info('repoDir set to ', repoDir); diff --git a/packages/runtime/src/modules/repo.ts b/packages/runtime/src/modules/repo.ts index d2c2d0ecd..a66ae23e9 100644 --- a/packages/runtime/src/modules/repo.ts +++ b/packages/runtime/src/modules/repo.ts @@ -2,6 +2,8 @@ import path from 'node:path'; import { readFile, writeFile, mkdir } from 'node:fs/promises'; import { defaultLogger, Logger } from '@openfn/logger'; import exec from '../util/exec'; +import * as os from 'node:os'; +const homeDir = os.homedir(); const defaultPkg = { name: 'openfn-repo', @@ -12,7 +14,7 @@ const defaultPkg = { dependencies: {}, }; -export const defaultRepoPath = '/tmp/openfn/repo'; +export const defaultRepoPath = path.join(homeDir, './openfn/repo/cli'); type InstallList = Array<{ name: string; version: string }>;