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

feat: add Stackable generator #2016

Merged
merged 14 commits into from
Jan 30, 2024
Merged

feat: add Stackable generator #2016

merged 14 commits into from
Jan 30, 2024

Conversation

ivan-tymoshenko
Copy link
Member

@ivan-tymoshenko ivan-tymoshenko commented Jan 26, 2024

Close #1861

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you add some docs?

packages/generators/lib/create-stackable-files.js Outdated Show resolved Hide resolved
`Generator` is a class extending `BaseGenerator` or any other stackable generator. It's used to generate the Stackable application. You can find an example of a generator in `lib/generator.js`.

```js
class Generator extends ServiceGenerator {
Copy link
Member

Choose a reason for hiding this comment

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

the requirefor this is missing

docs/guides/applications-with-stackables.md Show resolved Hide resolved
docs/guides/applications-with-stackables.md Show resolved Hide resolved
docs/guides/applications-with-stackables.md Show resolved Hide resolved

## Consuming a custom application
To create an application based on a Stackable you can run the `npm run create` cli command. This command uses the `cli/create.js` script to generate the application. By default application will be generated in the `./app` folder. As a next step you need to install the dependencies.
Copy link
Member

Choose a reason for hiding this comment

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

npm run create sounds a bit odd. I think you want to frame it as

  1. publish the module
  2. do a global install
  3. run the stackable command

(the publish/install could be replace with linking

Copy link
Member Author

Choose a reason for hiding this comment

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

When I'm developing a stackable I want to test it from time to time. The esiest way to do this it to generate a application. If I understand you correctly I would need to publish a stackable every time I make a change to be able to test it. Did I understand you correctly?

About linking. I'm not sure how it can be linked.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't be surprized if 90% of people that would try it don't have an npm account to publish.

Copy link
Member

Choose a reason for hiding this comment

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

npm link is a thing.

Also running node cli/create.js --dir path/to/myapp is way nicer.
cli/create.js should also be set in the bin scripts.

Copy link
Member Author

Choose a reason for hiding this comment

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

npm link is a thing.

I mean I don't understand where I can link it. I have a generated stackable project and globally installed platformatic. What it the next step?

Copy link
Member

Choose a reason for hiding this comment

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

npm link --global would make the bins available globally

Copy link
Member Author

Choose a reason for hiding this comment

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

Also running node cli/create.js --dir path/to/myapp is way nicer.

npm run create executes commmand exactly like this
https://github.com/platformatic/platformatic/pull/2016/files#diff-90f9d2ea47f8756b57ede9621e150c414c1a5963ac1b5c33825fb03942262c72R242

Copy link
Member

Choose a reason for hiding this comment

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

I would not recommend running a generator inside the same folder I'm currently working on. It just creates a local mess, which could possibly ruin what I'm currently working on. It's better to run it in an external folder.

docs/guides/applications-with-stackables.md Show resolved Hide resolved
const config = {
$schema: './stackable.schema.json',
greeting: {
text: this.config.greeting ?? 'Hello world!'
Copy link
Member

Choose a reason for hiding this comment

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

should be an ENV variable (also show how to add this to the env)

main: 'index.js',
scripts: {
'build:config': 'node lib/schema.js | json2ts > config.d.ts',
create: 'node cli/create.js --dir ./app',
Copy link
Member

Choose a reason for hiding this comment

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

cli/create.js must be exposed as a bin

Copy link

socket-security bot commented Jan 30, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/change-case-all@2.1.0 None +4 97.8 kB btxtiger

View full report↗︎

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

marcopiraccini

This comment was marked as duplicate.

Copy link
Contributor

@marcopiraccini marcopiraccini left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 864a6cc into main Jan 30, 2024
86 of 87 checks passed
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.

create-platformatic-auto follow ups
3 participants