Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/gentle-goats-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@openfn/engine-multi': minor
'@openfn/runtime': minor
'@openfn/cli': minor
---

Update default repo directory to be relative to homedir
5 changes: 5 additions & 0 deletions .changeset/short-rules-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/cli': patch
---

apollo: update staging url
3 changes: 1 addition & 2 deletions packages/cli/src/apollo/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/constants.ts

This file was deleted.

16 changes: 2 additions & 14 deletions packages/cli/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/options/repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
});

Expand Down
5 changes: 3 additions & 2 deletions packages/engine-multi/src/api.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -23,7 +25,7 @@ export type LazyResolvers = {

export type APIOptions = Partial<Omit<EngineOptions, 'whitelist'>>;

const DEFAULT_REPO_DIR = '/tmp/openfn/worker/repo';
const DEFAULT_REPO_DIR = path.join(os.homedir(), '.openfn/worker/repo');

const DEFAULT_MEMORY_LIMIT = 500;

Expand All @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/modules/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 }>;

Expand Down
Loading