Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Change to not look for node_modules path directly #1144

Merged
merged 1 commit into from
Feb 24, 2022

Conversation

2hoyeong
Copy link
Contributor

This PR is related to #1118 #1119

Sorry i missed.
It works Yarn(v3.1.1) and NPM

Please any feedback :)

@2hoyeong
Copy link
Contributor Author

@NicolasCARPi Did you review this PR?

@NicolasCARPi
Copy link
Contributor

Please explain how it is supposed to work when the dependencies are installed with yarn berry (and node_modules folder doesn't exist anymore).

Maybe I'm doing something wrong, this is what I tried:
2022-02-18-154333_1567x721_scrot

@2hoyeong
Copy link
Contributor Author

2hoyeong commented Feb 19, 2022

This is not to make apidoc run in yarn, but rather a feature that makes apidoc run in packages running with yarn.

Since Yarn v2 does not use node_modules, Finding assets in node_modules does not work properly.

So I changed to the JS API require.resolve. This is how they describe: https://yarnpkg.com/features/pnp#packages-are-stored-inside-zip-archives-how-can-i-access-their-files

The error occurred because you did not do npm install.

you can test like this

  1. In apidoc
    1. npm install
    2. npm run build-example
  2. In another yarn v2 project
    1. yarn add apidoc(This branch)
    2. Make doc files (Copy build exmple files in apidoc)
    3. apidoc build with yarn ex) yarn apidoc -c apidoc/apidoc.json -i apidoc/ -o apidocDist/

@NicolasCARPi
Copy link
Contributor

I tried what you suggested and it still cannot find dependencies.

verbose: Writing files...
verbose: Copying template index.html to: out/
verbose: Copying fonts to: /tmp/project/out/assets
verbose: Copying bootstrap css to: /tmp/project/out/assets
error: Could not find where dependencies of apidoc live!
error: The "path" argument must be of type string. Received undefined
debug: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:120:11)
    at Object.isAbsolute (node:path:1157:5)
    at VirtualFS.mapToBase (/tmp/project/.pnp.cjs:7018:24)
    at VirtualFS.lstatSync (/tmp/project/.pnp.cjs:6807:39)
    at PosixFS.lstatSync (/tmp/project/.pnp.cjs:6807:24)
    at URLFS.lstatSync (/tmp/project/.pnp.cjs:6807:24)
    at Object.lstatSync (/tmp/project/.yarn/cache/graceful-fs-npm-4.2.9-ee48e00aaa-68ea4e07ff.zip/node_modules/graceful-fs/polyfills.js:311:34)
    at statFunc (/tmp/project/.yarn/cache/fs-extra-npm-10.0.1-7c8ee14050-c1faaa5eb9.zip/node_modules/fs-extra/lib/util/stat.js:24:20)
    at getStatsSync (/tmp/project/.yarn/cache/fs-extra-npm-10.0.1-7c8ee14050-c1faaa5eb9.zip/node_modules/fs-extra/lib/util/stat.js:25:19)
[error] apidoc encountered an error during documentation generation!

@2hoyeong
Copy link
Contributor Author

I tried what you suggested and it still cannot find dependencies.

You have a reproducable repo? That's the error I fixed.

or Please make sure this branch is installed.

  1. yarn unplug apidoc
  2. You can find apidoc in .yarn/unplugged
  3. And check writer.js is changed as this PR

@NicolasCARPi
Copy link
Contributor

@2hoyeong
Copy link
Contributor Author

You should not install in that way.

You should try this yarn add apidoc@https://github.com/2hoyeong/apidoc.git#support-for-yarn-berry

@NicolasCARPi
Copy link
Contributor

Ok now it works! Thanks!

@NicolasCARPi NicolasCARPi merged commit d369b2e into apidoc:dev Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants