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

Runtime and Compiler v2 #11

Merged
merged 263 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
263 commits
Select commit Hold shift + click to select a range
5d410d4
Start a basic server which runs a job on POST requests
josephjclark Aug 25, 2022
519d22b
Update tsconfig and update tests
josephjclark Aug 25, 2022
a0fdfe5
Light refactoring
josephjclark Aug 26, 2022
9d48d79
Tryinf (and failing) to send messages through piscina
josephjclark Aug 26, 2022
2c207d2
Use workerpools for proper nessaging between threads
josephjclark Aug 26, 2022
9247166
Update ts config (again)
josephjclark Aug 26, 2022
61f71f2
Disable type checking in ava
josephjclark Aug 26, 2022
5be0607
Allow simple job queues to be pre-parsed rather than loaded as modules
josephjclark Aug 26, 2022
b3a3843
Added a mock worker function
josephjclark Aug 26, 2022
7f4f575
Moved @openfn/compiler -> @openfn/describe-package
josephjclark Aug 30, 2022
3be12a8
Added new compiler project with simple parse function
josephjclark Aug 30, 2022
4a3118f
Use recast for parsing
josephjclark Aug 30, 2022
567f92a
Start working out the transform infrastructure
josephjclark Aug 30, 2022
9b5c382
Get an ensure exports transformer working
josephjclark Aug 30, 2022
5903308
Little update to tests
josephjclark Aug 30, 2022
386e6b3
Update CLi (and docs); add top-level-operation transforms and tests
josephjclark Aug 31, 2022
16743e3
fix tsconfig in describe-package
josephjclark Aug 31, 2022
f62572d
Update and fix build
josephjclark Aug 31, 2022
e2fd620
Integrate compiler into runtime manager, update tests
josephjclark Aug 31, 2022
9f3e351
Let compiler detect whether incoming string is a path or source. Upda…
josephjclark Aug 31, 2022
8c4d22c
Randomise time of slow job
josephjclark Aug 31, 2022
0770f32
Start setting up new devtools
josephjclark Aug 31, 2022
5735819
Docs and tidying in runtime
josephjclark Sep 1, 2022
d4699e8
Round out cli functionality a bit
josephjclark Sep 1, 2022
17524ae
Documentation and tidyups
josephjclark Sep 1, 2022
a50b32e
Merge branch 'main' into v2
josephjclark Sep 1, 2022
e2be7ee
Package updates and README changes
stuartc Sep 9, 2022
0ada53a
Allow a modulesHome folder to be passed to the linker for module reso…
josephjclark Sep 13, 2022
1d1d58b
Add support for OPENFN_MODULES_HOME to the CLI, so that dynamic linki…
josephjclark Sep 13, 2022
d3f3ada
Run the actual command in a subprocess so that we can obfuscate the n…
josephjclark Sep 13, 2022
f950055
fix readme
josephjclark Sep 13, 2022
8c9d4a4
Documentation
josephjclark Sep 14, 2022
2cd8aa6
Refactoring tests and types
josephjclark Sep 14, 2022
4b1bfcf
Had a go at adding unit tests for the sCLI
josephjclark Sep 14, 2022
3b01cfa
Expand CLI tests
josephjclark Sep 14, 2022
4c67501
docs
josephjclark Sep 14, 2022
412e225
Fixed an issue compiling nested function calls at the top level
josephjclark Sep 14, 2022
3b22778
cli: Added option to trace linker module resolution
josephjclark Sep 15, 2022
aeaf40f
Add global state to runtime context (tmp)
josephjclark Sep 15, 2022
fffe357
compiler: Add a transformer to add an import statement given a module…
josephjclark Sep 15, 2022
11883ae
compiler: restructure tests, fix member expressions
josephjclark Sep 16, 2022
1a173d4
compiler: sundry type fixes
josephjclark Sep 16, 2022
adae5ea
describe-package: add rollup build
josephjclark Sep 16, 2022
065fbfe
Update describe-package import, fix tests
josephjclark Sep 16, 2022
b96e3ff
Enable the CLI to load exports for a module.
josephjclark Sep 16, 2022
3ef7461
describe-package: add unit tests on describeDts
josephjclark Sep 20, 2022
81e930b
runtime: avoid clever @openfn path mapping in the linker
josephjclark Sep 20, 2022
43ccd06
cli: sort of fix unit test to auto-import language common
josephjclark Sep 20, 2022
2b1e578
Big restructure along the line sof compile
josephjclark Sep 20, 2022
650f24e
cli: Added bin stub and update docs
josephjclark Sep 21, 2022
7b4bdc1
Improve yargs help and throw error if path not provided
josephjclark Sep 21, 2022
277d12f
Added deps and node native modules to rollup externals
stuartc Sep 21, 2022
5b38a5e
cli: Fixed issue resolving the path to the forked process script
josephjclark Sep 21, 2022
33a4206
cli: child-process -> runner; build tidy
josephjclark Sep 21, 2022
4e740f2
Merge branch 'v2' of https://github.com/OpenFn/kit into v2
josephjclark Sep 21, 2022
4a1ef0b
compiler: if there are no known imports for an adaptor, import any no…
josephjclark Sep 21, 2022
cb8669c
Added a compile-only flag to the CLI
josephjclark Sep 21, 2022
529df93
Docs tweak
josephjclark Sep 21, 2022
14ddfa8
describe-package: promote rollup to main build
josephjclark Sep 22, 2022
8da6b6c
describe-package: version bump
josephjclark Sep 22, 2022
ba59163
Bump versions, compiler and cli
stuartc Sep 22, 2022
1fc28fa
Add changeset support
josephjclark Sep 22, 2022
3f6dc98
Add initial changeset
josephjclark Sep 22, 2022
b1163a6
runtime: remove runtime dependency on @openfn/language-common, light …
josephjclark Sep 22, 2022
b5ce654
Add changeset for for runtime changes
josephjclark Sep 22, 2022
395ee51
First 'release' using changesets
stuartc Sep 22, 2022
8ddd910
Fix builds
stuartc Sep 22, 2022
eb5786c
Merge pull request #21 from OpenFn/changesets
stuartc Sep 22, 2022
8148cd5
Update build stuff
josephjclark Sep 22, 2022
86a9722
Added a utility to build a self-contained package
josephjclark Sep 28, 2022
a35af83
Add gzipping to the tarball
josephjclark Sep 28, 2022
988f321
Updated docs
josephjclark Sep 28, 2022
df36f9f
cli: Added a version utility function, and some refactoring of the ch…
josephjclark Sep 28, 2022
8a5311b
Added changeset for version util
josephjclark Sep 28, 2022
a04e8dd
Fix local pack and describe-package dependencies
josephjclark Sep 28, 2022
65a45ca
Remove version util in favour of the yargs default, which is more stable
josephjclark Sep 28, 2022
f3a1011
cli: added --test command
josephjclark Sep 28, 2022
27c6434
Update changesets
josephjclark Sep 28, 2022
7168944
Update CLI help
josephjclark Sep 28, 2022
27a5929
version bumps
stuartc Sep 27, 2022
9ff6f9a
version bump
stuartc Sep 29, 2022
0e10a53
changeset publish public
stuartc Sep 29, 2022
1dc992e
Change release command to use changeset
stuartc Sep 29, 2022
fb2b570
cli: Fix version warning in yargs
josephjclark Sep 29, 2022
66ce84d
workflow-diagram: port tests into ava
josephjclark Sep 29, 2022
014d57e
runtime-manager: fix tests
josephjclark Sep 29, 2022
7d38a6c
Update lockfile
josephjclark Sep 29, 2022
6e1cec2
Add build to circle config; Update top package dependencies
josephjclark Sep 29, 2022
c1922a2
Update lockfile
josephjclark Sep 29, 2022
5ee00db
Enable the compiler to expot all from adaptors
josephjclark Sep 27, 2022
e235aeb
Allow the runtime to respect and use the execute export
josephjclark Sep 29, 2022
b354525
cli: exportAll from adaptors, add test of custom execute
josephjclark Sep 29, 2022
5623913
changeset for custom execute
josephjclark Sep 29, 2022
e7f0b06
Update release process in the readme
josephjclark Sep 29, 2022
2e0d282
version bump
stuartc Sep 29, 2022
03f3612
logger: just some scrappy notes thinking about an api
josephjclark Sep 22, 2022
990c89d
Started created a unified, adaptable logger
josephjclark Sep 22, 2022
ce02e56
logger: notes
josephjclark Sep 27, 2022
7955801
logger: deeper integration to components, better outputs, tests
josephjclark Sep 29, 2022
91482d5
Re-structure handling of options, new unit tests to match
josephjclark Sep 30, 2022
1a1cdba
Got last tests working
josephjclark Sep 30, 2022
29b17c8
cli, logger, compiler: use new log level options in the compiler and cli
josephjclark Sep 30, 2022
c88171a
logger: add a mock logger which doesn't print to console
josephjclark Sep 30, 2022
19803ef
compiler: export Options type
josephjclark Sep 30, 2022
47ca24c
cli: more refactoring around the logger. Restored all tests
josephjclark Sep 30, 2022
7199862
logger: big refactor to simplify interface
josephjclark Oct 4, 2022
b200340
logger: return options object
josephjclark Oct 4, 2022
e6d6f55
cli: take advantage of better logger API
josephjclark Oct 4, 2022
8e3aeea
logger: add output parser to mock logger
josephjclark Oct 4, 2022
c2def8d
compiler: set up default loggers and fix tests
josephjclark Oct 4, 2022
ce3d9de
runtime: add support for new logger
josephjclark Oct 4, 2022
1f5c3b5
cli: Use runtime logging
josephjclark Oct 4, 2022
b1db718
Update lockfile
josephjclark Oct 4, 2022
36f237d
Fix various typings
josephjclark Oct 4, 2022
a961dec
compiler: type tweaks
josephjclark Oct 5, 2022
2ba14ea
logger: tidy typings
josephjclark Oct 5, 2022
9d338c5
logger: added really simple sanitizing function
josephjclark Oct 5, 2022
4b78249
update help a little bit
josephjclark Oct 5, 2022
a40b3d8
logger: added a validation util
josephjclark Oct 5, 2022
a8135c7
Use shorter names in logger output
josephjclark Oct 5, 2022
2fc87bf
Remove silent and traceLinker options
josephjclark Oct 5, 2022
c1916c2
logger: add simple duration formatter
josephjclark Oct 5, 2022
656516c
compiler,runtime: print durations
josephjclark Oct 5, 2022
f79bf9a
Added a changeset for logger stuff
josephjclark Oct 5, 2022
b26a40b
compiler: refactor transformers to be a bit clearer and simpler
josephjclark Oct 5, 2022
33dc68a
typo in comment
josephjclark Oct 5, 2022
e5c03ef
Merge pull request #26 from OpenFn/logger
josephjclark Oct 5, 2022
c3ac471
Restore correct default log level
josephjclark Oct 5, 2022
f49fec2
Merge previous compiler and runtime version bump
stuartc Oct 11, 2022
4bea0ed
bump versions
stuartc Oct 11, 2022
189171c
bump versions, fix broken package.json
stuartc Oct 11, 2022
45c19d0
version bump, broken package.json
stuartc Oct 11, 2022
f7224d3
noop
stuartc Oct 11, 2022
92e5427
bump all versions, npm package.json issue
stuartc Oct 11, 2022
36814c5
bump all versions, npm package.json issue
stuartc Oct 11, 2022
ecbbc1b
compiler: don't treat property names as dangling identifiers
josephjclark Oct 11, 2022
2066074
compiler: support ~ in adaptor paths
josephjclark Oct 11, 2022
1d293ae
added changeset
josephjclark Oct 11, 2022
9bb86f8
prettier tweak
josephjclark Oct 11, 2022
61bbbe8
bump versions
stuartc Oct 12, 2022
57725d4
Use esbuild to build the logger
josephjclark Oct 7, 2022
c2d5ca8
Dropped in tsup for an ebuild with nice d.t.s generation
josephjclark Oct 7, 2022
2c7d9bd
Remove unused config from tsconfig.common
josephjclark Oct 7, 2022
8a3ac5d
Aggressive skinning of common tsconfig
josephjclark Oct 7, 2022
d7d4558
Adjust logger dependencies
josephjclark Oct 7, 2022
6ccba72
Updated compiler build and fixed logger exports (grr)
josephjclark Oct 7, 2022
5a8cc39
Update cli build
josephjclark Oct 7, 2022
6c16e33
Update runtime build
josephjclark Oct 7, 2022
2c15bec
Update runtime-manager build
josephjclark Oct 7, 2022
1cd2023
update describe-package build
josephjclark Oct 7, 2022
c06db83
update package lock
josephjclark Oct 7, 2022
28168a8
Added changeset
josephjclark Oct 7, 2022
42f68fb
revert top level module
josephjclark Oct 7, 2022
ae88679
Added type check to circle ci
josephjclark Oct 7, 2022
4021499
Fix typo in circle config
josephjclark Oct 7, 2022
9225d85
remove type check from ci
josephjclark Oct 7, 2022
608d885
Fix runtime manager build
josephjclark Oct 7, 2022
660c6ef
Update package authors
josephjclark Oct 7, 2022
0399f9c
logger: update readme
josephjclark Oct 7, 2022
c329772
logger: check types in tests
josephjclark Oct 7, 2022
20bc216
run prettier on logger
josephjclark Oct 7, 2022
6d165a5
cli: prettier
josephjclark Oct 7, 2022
5d1b193
compiler: run prettier
josephjclark Oct 7, 2022
f362d18
log to null by default
josephjclark Oct 7, 2022
0fef5e9
runtime: prettier
josephjclark Oct 7, 2022
65b264c
runtime: run tsc on tests
josephjclark Oct 7, 2022
c46597d
runtime-manager: prettier
josephjclark Oct 7, 2022
8588ced
cli: tsc on test
josephjclark Oct 7, 2022
a823cc9
downgrade ts-node for logger as it was randomly failing??
josephjclark Oct 7, 2022
0033ad6
Update authors
josephjclark Oct 7, 2022
87090f7
compiler: remove unused rollup config
josephjclark Oct 27, 2022
b371763
tweak package manifests
josephjclark Oct 27, 2022
07e62fe
adjust ts settings
josephjclark Oct 27, 2022
cda9984
runtime: remove unused esbuild dependency
josephjclark Oct 27, 2022
304528b
Merge pull request #32 from OpenFn/v2-tidy
josephjclark Oct 27, 2022
4446a22
runtime: only use immutable state if a flag is set
josephjclark Oct 27, 2022
c7523a4
Support immutable flag in the CLI
josephjclark Oct 27, 2022
6d1d199
Add changeset
josephjclark Oct 27, 2022
47931eb
compiler: update the list of globals to not auto-import
josephjclark Nov 1, 2022
41bdfdc
changeset
josephjclark Nov 1, 2022
02dbe61
Update versions
josephjclark Nov 1, 2022
11cfc0b
Manually update changelogs
josephjclark Nov 1, 2022
bc1ed6f
Updated package lock
josephjclark Nov 1, 2022
b1ebd96
Updated changeset version
stuartc Nov 2, 2022
c18a4b0
Updated changeset version
stuartc Nov 2, 2022
5371af0
Merged changelogs
josephjclark Nov 3, 2022
68f234a
Merge pull request #54 from OpenFn/import-globals
josephjclark Nov 3, 2022
65c9a53
runtime: Added some basic module management apis
josephjclark Oct 28, 2022
7a5fa70
Enable the linker to use the repo
josephjclark Oct 28, 2022
0e1e228
runtime: fix is-module-installed
josephjclark Nov 1, 2022
da13aa9
cli: major refactor to allow proper commands, plus a new openfn insta…
josephjclark Nov 1, 2022
285d24d
runtime: restore some sanity to the repo
josephjclark Nov 2, 2022
3d3c686
runtime: update main exports
josephjclark Nov 2, 2022
67b0f67
runtime: use the logger in install
josephjclark Nov 2, 2022
7846049
cli: autoinstall now works, compiler exports preload uses modulesHome
josephjclark Nov 2, 2022
adc7135
Update package lock
josephjclark Nov 2, 2022
20f4e8d
runtime: remove modulesHome, update tests & readme
josephjclark Nov 2, 2022
001d9e9
runtime: some tidying
josephjclark Nov 2, 2022
0625cf6
runtime: fix an issue initing a new repo
josephjclark Nov 2, 2022
fda5fac
cli: pass repo to linker instead of modulesHome
josephjclark Nov 2, 2022
91cd64a
Export a default logger for easy consumption
josephjclark Nov 3, 2022
e9cbc06
changeset: logger
josephjclark Nov 3, 2022
e9f94ff
cli: use default logger in install
josephjclark Nov 3, 2022
587c27a
Refactor repo stuff into a single file; add unit tests
josephjclark Nov 3, 2022
d80997e
cli: Another big refactor to break up command structure and allow rep…
josephjclark Nov 3, 2022
2e471a8
runtime: tweak repo utils
josephjclark Nov 3, 2022
0852317
compiler: remove comment
josephjclark Nov 3, 2022
7b39345
cli: don't lookup module defs from unpkg; improve module resolution; …
josephjclark Nov 3, 2022
e129913
cli: add test repo
josephjclark Nov 3, 2022
e17d4e1
cli: update readme, restore some logger tests
josephjclark Nov 3, 2022
1e1d30c
cli: added repo pwd utility
josephjclark Nov 3, 2022
ae33a15
cli: add repo list
josephjclark Nov 3, 2022
82d6402
cli: workaround type issue
josephjclark Nov 3, 2022
202ee74
cli: modulesHome -> repoDir
josephjclark Nov 4, 2022
f1a957c
logger: add confirm utility function
josephjclark Nov 4, 2022
1a1b234
cli: added a confirm prompt to repo clean
josephjclark Nov 4, 2022
9e63e9d
runtime: allow install of multiple packages
josephjclark Nov 4, 2022
cf6fd1c
runtime: tweak install log output
josephjclark Nov 4, 2022
f604cda
cli: support install of multiple adaptors
josephjclark Nov 4, 2022
7569f9d
cli: logging tweaks
josephjclark Nov 4, 2022
b45dcf4
cli: add duration to installation result
josephjclark Nov 4, 2022
6777383
logger: add a better timer function
josephjclark Nov 4, 2022
1adf3e1
cli: update logging
josephjclark Nov 4, 2022
ef9406b
changeset: autoinstall
josephjclark Nov 4, 2022
e663102
cli: remove unused line
josephjclark Nov 4, 2022
f2f8914
CLI: ensure adaptor shorthands can be expanded
josephjclark Nov 4, 2022
7c1b538
Update docs
josephjclark Nov 4, 2022
1dfc036
cli: allow adaptor expand behaviour to be disabled (for unit tests)
josephjclark Nov 4, 2022
754c3b1
Merge pull request #56 from OpenFn/autoinstall
stuartc Nov 7, 2022
ae20d77
Update node to 18 on ci
stuartc Nov 7, 2022
73d8199
Fix default repo location typo
stuartc Nov 7, 2022
2bcbed7
Fix typo
stuartc Nov 7, 2022
049bf66
Merge branch 'main' into v2
josephjclark Nov 8, 2022
d1cd9c1
workflow-diagram: fix merge stuff
josephjclark Nov 8, 2022
75fa8ec
workflow-diagram:Restore missing file
josephjclark Nov 8, 2022
63a79b9
workflow-dialogram: remove unused file
josephjclark Nov 8, 2022
92ea7d8
Update top readme
josephjclark Nov 8, 2022
15797a5
Update docs
josephjclark Nov 8, 2022
077b849
Docs fix
josephjclark Nov 8, 2022
81adb51
describe-package: restore worker bundle
josephjclark Nov 8, 2022
909e031
compiler-worker: fixed build
josephjclark Nov 8, 2022
7f7a1ab
examples: compiler-worker -> dts-inspector
josephjclark Nov 8, 2022
14c2c5e
tweak readme
josephjclark Nov 8, 2022
1473b78
tweak readme again
josephjclark Nov 8, 2022
56d33d9
update package lock
josephjclark Nov 8, 2022
07fda1d
skip failing test
josephjclark Nov 8, 2022
3222eee
describe-package: update failing test
josephjclark Nov 8, 2022
f6c9771
describe-package: remove dead code
josephjclark Nov 8, 2022
6c57303
changeset
josephjclark Nov 8, 2022
eb52b0d
Merge pull request #61 from OpenFn/tidy-project
josephjclark Nov 8, 2022
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
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.1.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/eight-donuts-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/logger': patch
---

Added a confirm utility
6 changes: 6 additions & 0 deletions .changeset/gold-glasses-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@openfn/cli': patch
'@openfn/runtime': patch
---

Support auto-install of modules
5 changes: 5 additions & 0 deletions .changeset/great-seas-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/runtime': patch
---

Fix default repo location typo
5 changes: 5 additions & 0 deletions .changeset/sour-points-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/describe-package': patch
---

Include worker bundle in package
5 changes: 5 additions & 0 deletions .changeset/thick-otters-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/logger': patch
---

Export a default logger
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/node:16.15
- image: cimg/node:18.12
resource_class: medium
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
steps:
- run:
name: Install pnpm
command: corepack enable && corepack prepare pnpm@7.5.1 --activate
command: corepack enable && corepack prepare pnpm@7.14.2 --activate
- checkout
- restore_cache:
# See the configuration reference documentation for more details on using restore_cache and save_cache steps
Expand All @@ -30,6 +30,9 @@ jobs:
key: deps-v1-{{ .Branch }}-{{checksum "pnpm-lock.yaml"}}
paths:
- node_modules
- run:
name: Build packages
command: pnpm build
- run:
name: Run Tests
command: pnpm test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules
public/
!public/index.html
tsconfig.tsbuildinfo
ts.cache

# Build tools
.rollup.cache
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
*.md
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"tabWidth": 2,
"useTabs": false,
"printWidth": 80
"printWidth": 80,
"singleQuote": true
}
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.8.0
nodejs 18.12.1
121 changes: 104 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,129 @@
Lightning ProjectSpace
OpenFn Kit
======================

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/OpenFn/kit/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/OpenFn/kit/tree/main)

**Kit** _noun_ _/kɪt/_

A set of articles or equipment needed for a specific purpose.

1. _a football kit_
1. _the next-generation openfn data integration kit_

---

This repo contains runtime, tooling, libraries and components to support the next generation core openfn data integration pipeline.

It is a kitbag of Javascript-based components to support Lightning.

## Prerequisities

* [asdf](https://github.com/asdf-vm/asdf)
* [pnpm](https://pnpm.io/installation)

We use [asdf](https://github.com/asdf-vm/asdf) to configure our local
environments and ensure consistency of versions.

You should install asdf and the [NodeJs](https://github.com/asdf-vm/asdf-nodejs) plugin.

We use [`pnpm`](https://pnpm.io/installation), a fast, disk space efficient package manager, to handle node dependencies within the repo.

## Installing

- Install [`pnpm`](https://pnpm.io/installation)
- Run `pnpm run setup`
- Run `pnpm run build`
- `$ pnpm run setup`
- `$ pnpm build`

## Packages
## Running Tests

- [`@openfn/compiler`](packages/compiler)
- [`@openfn/workflow-diagram`](packages/workflow-diagram)
```
pnpm run test
```

# Development Guide

Thanks for being here! You're contributing to a digital public good that will always be free and open source and aimed at serving innovative NGOs, governments, and social impact organizations the world over! You rock ❤️

## Releases & Changesets

## Examples
We use changesets to manage releases: [`github.com/changesets`](https://github.com/changesets/changesets)

The example apps serve to illustrate how these packages can be used, and also
for development, any changes detected in the dependencies will trigger a rebuild in the example.
A changeset is a description of batch of changes, coupled with semver information.

**ProjectSpace Flow**
### Adding a change

When submitting a PR against this repo, include a changeset to describe your work.

```
pnpm run -C examples/flow start
pnpm changeset
```

**Compiler Worker**
For example changeset notes, look in the `.changesets` folder.

### Releasing

To relase to npm:

1) Update versions
```
pnpm run -C examples/compiler-worker start
pnpm changeset version
```

## Running Tests
This will automatically update the version numbers of the affected packages.

Commit the changes:

```
pnpm run test
git commit -am "Updated changeset version"
```

2) Rebuild
```
pnpm install
pnpm build
```

3) Test

Build the test bundle:
```
$ pnpm clean:local
$ pnpm pack:local
```

Install using command reported by pack:local (`npm install -g dist/openfn-cli-<version>-local.tgz`)

Sanity check the version and ensure it works:
```
$ openfn --version
$ openfn test
```

3) Publish

```
pnpm changeset publish --otp <OTP>
```

## Testing the built package

You can test the built CLI package to ensure it works before publishing it.

The `build/pack-local` script is an overly complicated solution which:
* Packs all the openfn packages
* Updates the dependencies to use peer packages in dist, rather than module names
* Creates `openfn-cli-<version>-local.tgz` which you can install globally.

To run the test:

```
$ pnpm build
$ pnpm clean:local
$ pnpm pack:local
```

Run the install command as printed in your shell - something like `npm -g dist/openfn-cli-local.tgz`

You can run `openfn test` to exercise the runtime and compiler.

## Documentation

For information on the history of the OpenFn internals and ideas for the future
Expand Down
19 changes: 19 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
extensions: {
ts: "module"
},

environmentVariables: {
"TS_NODE_TRANSPILE_ONLY": "true"
},

nodeArguments: [
"--loader=ts-node/esm",
"--no-warnings", // Disable experimental module warnings
"--experimental-vm-modules"
],

files: [
"test/**/*test.ts"
]
}
101 changes: 101 additions & 0 deletions build/pack-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* This will load each of the built .tgzs, extract them in-memory,
* update @openfn dependencies in package.json to use absolute local paths,
* And write back to disk.
*/
const path = require('node:path')
const fs = require('node:fs');
const { createGzip } = require('node:zlib');
const tarStream = require('tar-stream');
const gunzip = require('gunzip-maybe');

async function findPackages() {
return new Promise((resolve) => {
fs.readdir(path.resolve('dist'), { encoding: 'utf8' }, (err, files) => {
resolve(files.filter(p => p.endsWith('tgz')));
});
});
}

const getLocalTarballName = (packagePath) => packagePath.replace('.tgz', '-local.tgz');

function processPackageJSON(stream, packageMap, pack) {
return new Promise(resolve => {
const data = [];
stream.on('data', c => data.push(c))
stream.on('end', () => {
const buf = Buffer.concat(data)

const pkg = JSON.parse(buf.toString('utf8'));
for (const dep in pkg.dependencies) {
if (packageMap[dep]) {
console.log(`Mapping ${dep} to ${packageMap[dep]}`)
pkg.dependencies[dep] = getLocalTarballName(packageMap[dep]);
}
}
pack.entry({ name: 'package/package.json' }, JSON.stringify(pkg, null, 2), resolve)
});
});
}

function updatePkg(packageMap, filename) {
const pkgPath = `dist/${filename}`;
console.log(' - Updating package', pkgPath)

// The packer contains the new (gzipped) tarball
const pack = tarStream.pack();
pack.pipe(createGzip());

return new Promise((resolve) => {
// The extractor streams the old tarball
var extract = tarStream.extract();
extract.on('entry', (header, stream, next) => {
if (header.name === 'package/package.json') {
processPackageJSON(stream, packageMap, pack).then(next)
}
else {
stream.pipe(pack.entry(header, next));
}
});

// Pipe to a -local file name
// Reading and writing to the same tarball seems to cause problems, funnily enough
const out = fs.createWriteStream(getLocalTarballName(pkgPath))
// Note that we have to start piping to the output stream immediately,
// otherwise we get backpressure fails on the pack stream
pack.pipe(out);

fs.createReadStream(pkgPath)
.pipe(gunzip())
.pipe(extract)

extract.on('finish', () => {
pack.finalize()
resolve();
});
});
}

// Map the tgz packages in dist to npm package names
const mapPackages = (files) => {
return files.reduce((obj, file) => {
const mapped = /openfn-(.+)-\d+\.\d+\.\d+\.tgz/.exec(file)
if (mapped && mapped[1]) {
obj[`@openfn/${mapped[1]}`] = path.resolve('dist', file);
}
return obj;
}, {});
}

findPackages().then(async (files) => {
const pkgs = mapPackages(files);
Promise.all(files.map((f) => updatePkg(pkgs, f))).then(() => {
const cliPath = getLocalTarballName(pkgs['@openfn/cli']);
console.log();
console.log('Build complete!');
console.log(`Install the CLI from ${cliPath} with the command below:`)
console.log();
console.log(` npm install -g ${cliPath}`)
})
})

22 changes: 22 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Examples

The example apps serve to illustrate how these packages can be used, and also
for development, any changes detected in the dependencies will trigger a rebuild in the example.

**ProjectSpace Flow**

Uses packages/workflow-diagram

From root:
```
pnpm run -C examples/flow start
```

**DTS Inspector**

Uses packages/describe-package

From root:
```
pnpm run -C examples/describe-package start
```
Loading