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

Refactor: Move CLI create into its own package #1440

Closed

Conversation

rschristian
Copy link
Member

What kind of change does this PR introduce?

Refactor

Did you add tests for your changes?

No new tests, but old ones were updated/fixed

Summary

Currently the CLI performs two, mostly separate functions: creating new projects and running existing ones. With this combined functionality, the package is heavier than need be in both applications of the package. Especially now that npx is the suggested way to use the CLI to bootstrap new projects, having a lighter tool is very beneficial.

This PR would separate out the create functionality of the CLI into what I've temporarily called create-preact-app. I do believe that name is taken, so will likely need a different name.

This was mentioned in a comment on the change to use npx as a potential avenue for change in the future: #1355 (comment)

Does this PR introduce a breaking change?

I don't think this counts as breaking?

@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2020

⚠️ No Changeset found

Latest commit: 80bf763

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member Author

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

There's also a fair few stylistic changes done automatically by my IDE (and I didn't notice until now). I figure I'll keep them in, they look to be right. I can remove them if they make this too busy.

@@ -1,6 +1,7 @@
const { join } = require('path');
const { existsSync, unlinkSync, symlinkSync } = require('fs');
const cmd = require('../../lib/commands');
const create = require('../../../create-preact-app/lib/commands').create;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a bit messy, not sure if there's a better way

let prog = sade('create-preact-app').version(pkg.version);

prog
.command('create [template] [dest]', '', { default: true })
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 made this the default so it can be ran as npx create-preact-app default my-application. I figure that's better than the alternative npx create-preact-app create default my-application.

Comment on lines +1 to +15
const { blue, yellow, red } = require('kleur');

const main = {
info: blue('ℹ'),
warning: yellow('⚠'),
error: red('✖'),
};

const win = {
info: blue('i'),
warning: yellow('‼'),
error: red('×'),
};

module.exports = process.platform === 'win32' ? win : main;
Copy link
Member Author

Choose a reason for hiding this comment

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

Items like this (that are duplicated) might need suggestions from someone who's more experienced with mono-repos. Not sure if there's a better solution without introducing another package that holds some of this common stuff?

Comment on lines -40 to -45

// it('should fail given an invalid name', async () => {
// const exit = jest.spyOn(process, 'exit');
// await create('default', '*()@!#!$-invalid-name');
// expect(exit).toHaveBeenCalledWith(1);
// });
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed as this has been commented out and unused for 3 years: fef996e

@rschristian rschristian changed the title Refactor/separate create Refactor: Move CLI create into its own package Sep 29, 2020
@rschristian rschristian marked this pull request as ready for review September 30, 2020 23:27
@rschristian rschristian requested a review from a team as a code owner September 30, 2020 23:27
@ForsakenHarmony
Copy link
Member

Personally preferred having it in the same package, it was separate enough to me, but I'm fine with it if other people agree

@rschristian
Copy link
Member Author

It certainly adds some complexity to the repo and probably some slight duplication of code too.

Just an idea for a lighter (and therefore faster with npx) create.

@rschristian rschristian marked this pull request as draft October 10, 2020 18:52
@rschristian
Copy link
Member Author

Closing this as I'd like to redo it.

@rschristian rschristian deleted the refactor/separateCreate branch March 5, 2022 00:33
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.

None yet

2 participants