Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Collections support #839

Merged
merged 24 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
980f8ad
Added a fairly basic get handler
josephjclark Dec 5, 2024
778b3d1
collections: fix output default
josephjclark Dec 5, 2024
71cd2a6
cli: add collections-set support
josephjclark Dec 6, 2024
2bcd441
cli: adjust get data
josephjclark Dec 6, 2024
ce221d7
cli: tidy up PAT access
josephjclark Dec 6, 2024
0755630
cli: add collections. remove
josephjclark Dec 6, 2024
52f7d93
cli: comment
josephjclark Dec 6, 2024
92255d6
cli: clean up multi-get format
josephjclark Dec 7, 2024
d63dcf6
cli: start implementing collections tests
josephjclark Dec 7, 2024
0c053c8
cli: collections unit tests
josephjclark Dec 7, 2024
89636dd
cli: collections error handling and tests
josephjclark Dec 7, 2024
5cacdbe
cli: typings
josephjclark Dec 7, 2024
ec53eee
bump collections adaptor version
josephjclark Dec 8, 2024
98a2ed7
cli: better error handling in collections
josephjclark Dec 8, 2024
ae2ae93
cli: fix collections test
josephjclark Dec 9, 2024
82c0661
collections cli: support limit
josephjclark Dec 9, 2024
ba131cb
cli: hook up collections queries
josephjclark Dec 9, 2024
9731003
cli: force collections key to be a string
josephjclark Dec 10, 2024
16e8ed6
cli: fix typing
josephjclark Dec 11, 2024
7a3fa41
worker: fix a typo in logging
josephjclark Dec 11, 2024
03f5b40
cli: refactor REPO_DIR warning message
josephjclark Dec 11, 2024
3a95d3b
changeset
josephjclark Dec 11, 2024
e5acbaf
version: [email protected]
josephjclark Dec 11, 2024
483304a
Merge branch 'main' into collections-cli
josephjclark Dec 11, 2024
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
Prev Previous commit
Next Next commit
cli: refactor REPO_DIR warning message
  • Loading branch information
josephjclark committed Dec 11, 2024
commit 03f5b40656168bbdaff7daa8ced8117cda3e6fbb
5 changes: 5 additions & 0 deletions .changeset/lucky-pandas-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/cli': patch
---

Adjust OPENFN_REPO_DIR warning message
2 changes: 0 additions & 2 deletions packages/cli/src/collections/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ const key = {
},
};

// TODO this should default from env
// TODO this is used by other args
const token = {
name: 'pat',
yargs: {
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/collections/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export const set = async (options: SetOptions, logger: Logger) => {
} else if (options.key && options.value) {
const resolvedPath = path.resolve(options.value);
logger.debug('Loading value from ', resolvedPath);
// TODO throw if key contains a *

// set a single item
const data = await readFile(path.resolve(options.value), 'utf8');
Expand Down
19 changes: 0 additions & 19 deletions packages/cli/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,6 @@ const parse = async (options: Opts, log?: Logger) => {
) as string[];
}

// TODO Please fix this joe!
// Put the validation inside the repoDir option

// TODO it would be nice to do this in the repoDir option, but
// the logger isn't available yet
if (
!/^(pull|deploy|test|version|apollo|collections-get|collections-set)$/.test(
options.command!
) &&
!options.repoDir
) {
logger.warn(
'WARNING: no repo module dir found! Using the default (/tmp/repo)'
);
logger.warn(
'You should set OPENFN_REPO_DIR or pass --repoDir=some/path in to the CLI'
);
}

const handler = handlers[options.command!];

if (!handler) {
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ export const repoDir: CLIOption = {
description: 'Provide a path to the repo root dir',
default: process.env.OPENFN_REPO_DIR || DEFAULT_REPO_DIR,
}),
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