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

0.2.0: New structure, features, plugin, and SDK #9

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

khalidx
Copy link

@khalidx khalidx commented Feb 16, 2024

Up next

  • Fully folding run v1 into v2, with new run semantics
    • Run by section
    • Run by sha512 (for local/remote SDKs)
  • Fully folding sync v1 into v2, with new sync semantics, sources, and destinations
  • Tests
  • New basic polyglot runtime
  • What is a good experience for relative imports for users?
  • Move to preprocessor chain model so that we can do a series of transformations on markdown tree
  • Revamped README with complete reference/guide, and more examples, patterns, how-tos
  • Test plugin features after installing from npm
  • Add mapping to bun Zig runtime loader table and use --loader fallback
  • Support for combining files
  • Add files: [] array to package.json for automatic tar-ing of what we want to send to npm

List of changes

  • Added example to README
  • Relative imports for TypeScript users (from TS and from TS markdown blocks)
    • Like @/src/plugin/example.md
    • Unfortunately requires a tsconfig and a relative local path (at least for now)
  • Support for multiple os/platform/arch specifiers with the --os block flag
  • Separate structure for logging and running (not same file)
  • Separate files per content block (not combining bash and ts)
  • Bumping expected bun version to ^1.0.27
  • Using linear CLI arg parsing and branching
  • Using safer exitCode mechanism
  • User-facing CLI errors no longer show internal bundown source stack trace
  • Fixed bug where upgrade ignores $ exit code
  • ~2x speed improvement
  • Can resolve various URIs
    • file paths
    • directories
    • URLs
    • github://<org>/<repo>
    • gist://<user>/<id>
  • bundown can be imported as a library
  • Adding the bundown bun plugin
    • In JavaScript and TypeScript:
      • Support for import README from './README.md'
        • README.markdown.tree, README.blocks, README.run()
      • Support for import goProgram from './some/go/program.go'
        • const { exitCode, stdout, stderr } = goProgram.call()
      • Support for import pythonProgram from './some/python/program.py'
      • Support for import shellProgram from './some/python/program.sh'
    • Support for bun ./README.md
    • Support for bun <file> for sh, py, and go (and md, see above)
    • Bundown uses runtimes to run the languages above (map of lang => start script)
    • Support for bun <file> with custom runtimes with --bundown-runtime or --brrr
    • The bundown plugin for bun can now run various languages (see above)
    • The bundown plugin for bun can be used standalone in any bun project
    • This works, and is recursive:
      # example
      
      ```shell
      echo "Hello from example.md"
      ```
      
      ```typescript -t time
      console.log('This only runs with --tag "time"', Date.now())
      ```
      
      ```typescript -f ./src/plugin/test.ts
      console.log(`This won't run, since it uses -f`)
      ```
      
      ```typescript --os mac --os linux
      console.log(`This only runs on mac or linux`)
      ```
      
      ```python
      print("Python works too!")
      ```
      
      ```go
      package main
      
      import "fmt"
      
      func main() {
          fmt.Println("Go works too!")
      }
      ```
      
      ```typescript
      import EXAMPLE from '@/src/plugin/example.md'
      
      console.log('Hello from bundown!')
      
      // This is recursive.
      // Running example.md will execute the
      // bash and typescript blocks above.
      // Then, the following line will execute,
      // which runs example.md all over again!
      // It's bundown from inside bundown!
      // You probably don't want to keep this
      // running for too long though, since the
      // processes don't exit (yet)...
      EXAMPLE.run()
      ```
  • Updating v1 to use the new SDK
    • Moving to src directory
    • Stricter TypeScript config
    • More complete gitignore
    • Disabled bun telemetry
    • Enabled lock
    • Removed extra deps

@khalidx khalidx changed the title 0.2.0: New structure, features, and SDK 0.2.0: New structure, features, plugin, and SDK Feb 17, 2024
@khalidx khalidx marked this pull request as ready for review February 17, 2024 15:48
@@ -1,7 +1,187 @@
node_modules
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer we don't make this .gitignore change - the previous state was intentionally simple and focused on stuff that matters to us, I'm always happy to add more in to cover the fair needs of contributors, but a lot of the stuff in here is from things that as of right now should never be used in this repo and as far as I'm aware would never be used as a consequence of a contributor's setup (e.g. anything vue, parcel, npm/pnpm/yarn, or dynamodb related)

Can we revert the change here? Let me know if there's a specific item you want added in, but if there is let's just add it into the previous form of this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default .gitignore you get for node_modules, also for bun init. I think it has sane defaults. I added the ones you had too like *.pem. I don't care much about it though. Can revert.

preload = ["./src/plugin/register.ts"]

[install.lockfile]
print = "yarn"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think we should use the yarn.lock file, if we do want to commit a lockfile I prefer bun.lockb - you can optionally configure a yarn-style diff like this in your personal .gitconfig to see it in git diffs:

[diff "lockb"]
  textconv = bun
  binary = true

Overall though, this falls into the set of things I'd like to just keep simple and ideally not even have to use, not having a lockfile to begin with was intentional.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think not having a lockfile is the right way to go, we need to be able to see when/how our dependencies change at the very least

Comment on lines +27 to +29
"peerDependencies": {
"typescript": "^5.3.3"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default on bun init. Also we don't have any dependency on typescript (neither do consumers of bundown as a lib). That's why it isn't in the dependencies array.

os: { type: 'string', multiple: false },
}
})
const expectedBunVersion = '^1.0.27'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please move this back to the package.json import and set it back to 1.0.24?

The intent here is to require the minimum viable Bun version that can run Bundown, which so far means the earliest version supporting the $ Bun Shell. That information should just come from the package.json dependency.

This is also why the $ import was happening after the throw.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

import "fmt"

func main() {
fmt.Println("Go works too!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this tab to 2 or 4 spaces for now - the actual fix here should be a follow-up PR but currently it seems that tabs break our box drawing in print mode, so we should find and replace them with a set number of spaces when code is printed before string widths are calculated etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(When I say follow up PR in this case I just mean a future fix, doesn't necessarily have to be anybody specific implementing it or on any timeline, I don't consider it an urgent issue.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think the tabs were because of this just being copy-pasted from default go "hello world". I will fix.


/* Re-write import paths */
"paths": {
"@/*": ["./*"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit, let's use ~ instead of @

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@jrysana jrysana mentioned this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants