alvis / presetter

🛹 Reuse and manage build scripts, devDependencies and config files from your favourite presets, instead of copy and paste!
MIT License
68 stars 2 forks source link

Cannot set a preset in a fresh project using `presetter use` #8

Closed faassen closed 3 years ago

faassen commented 3 years ago

Here are some user reports as I think there are a few bugs that crept into v3. No rush, just playing with it.

I tried:

npx presetter use presetter-preset-strict

in an empty directory. This failed because

Error: failed to find target's package.json

No big deal but it might help to add a note in the README that you first need to initialize the package.

Then I tried

 npx presetter use presetter-preset-strict

But this crashes for me too:

Error: Missing preset defined in .presetterrc
    at getPresetterRC (/home/faassen/.npm/_npx/19815/lib/node_modules/presetter/source/preset.ts:66:9)
    at getContext (/home/faassen/.npm/_npx/19815/lib/node_modules/presetter/source/preset.ts:295:18)
    at setupPreset (/home/faassen/.npm/_npx/19815/lib/node_modules/presetter/source/preset.ts:198:19)

This seems to be a bug?

(Incidentally the error message is Error: Missing preset defined in .presetterrc but .presetterrc.json is the file I find inside presetter; maybe both work?)

Not being entirely sure, I also tried:

 npx presetter use presetter-preset-strict

(which one is it? The docs mention you can use preset-essentials but the package listing has the presetter- prefix)

And

npx presetter use preset-essentials

But give me the same error. So it looks like a correct .presetterrc is required.

So then I added:

{
  "preset": "presetter-preset-strict"
}

And did (weirdly enough, okay):

npx presetter use preset-essentials

But that doesn't work either as I get this:

HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/preset-essentials - Not found

So it is presetter-preset-essentials then, unlike what the README at first suggested. This does work:

npx presetter use presetter-preset-essentials

Unfortunately all my symlinks are broken. For some reason it's pointing to:

../../.npm/_npx/20288

And while ../../.npm/_npx exists, 20288 does not.

Trying it again with a new package, this time with a .presetterrc.json like this:

{
  "preset":  []
}

Nope, I still end up with broken symlinks.

Node version: v14.17.6 NPM version: 6.14.15

alvis commented 3 years ago

Thanks. I can reproduce the error with the following command:

npx presetter use presetter-preset-essentials

With node 16.10 npm 7.24

presetter use <preset..>

adopt the specified preset to the project

Positionals:
  preset  proceed only if the specified file exists
                                                [array] [required] [default: []]

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

TypeError: Cannot read properties of undefined (reading '0')

With node 14.18 npm 6.14.5

npx: installed 308 in 21.508s
presetter use <preset..>

adopt the specified preset to the project

Positionals:
  preset  proceed only if the specified file exists
                                                [array] [required] [default: []]

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Error: Missing preset defined in .presetterrc

There is a slight difference between the 2 npm versions.

alvis commented 3 years ago

As a side note, presetter does recognise the config file with or without the .json extension. So both .presetterrc and .presetterrc.json works.

alvis commented 3 years ago

@faassen The issue is now fixed with 3.0.1. both node 14 & 16 environments should work! Check it out. 😉