§2024-06-08

new naming conventions:

  • File and Directory Names in Linux: - Use snake case: my_project, data_backup_2024, config_files
  • Code Conventions in Node.js: - Use camel case for variables and functions: myVariableName, fetchUserData - Use Pascal case for class names: MyClass, UserModel

use fnm node version control

¶ 1. Create project directory as quickstart

機器: hc4Nas02.yushei.net

alexlai@hc4nas02:~$ pwd
/home/alexlai
alexlai@hc4nas02:~$ mkdir docsify_proj && cd $_
alexlai@hc4nas02:~/docsify_proj$ mkdir quickstart && cd $_
alexlai@hc4nas02:~/docsify_proj/quickstart$ which npm node
/run/user/1026/fnm_multishells/865354_1717806322043/bin/npm
/run/user/1026/fnm_multishells/865354_1717806322043/bin/node
alexlai@hc4nas02:~/docsify_proj/quickstart$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (quickstart) 
version: (1.0.0) 
description: docsify quickstart guide
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: alexlai@h2Jammy.yushei.net
license: (ISC) 
About to write to /home/alexlai/docsify_proj/quickstart/package.json:

{
  "name": "quickstart",
  "version": "1.0.0",
  "description": "docsify quickstart guide",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "alexlai@h2Jammy.yushei.net",
  "license": "ISC"
}


Is this OK? (yes) 

npm notice
npm notice New minor version of npm available! 10.7.0 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice To update run: npm install -g npm@10.8.1
npm notice
alexlai@hc4nas02:~/docsify_proj/quickstart$ npm install -g npm@10.8.1

removed 2 packages, and changed 63 packages in 12s

24 packages are looking for funding
  run `npm fund` for details
alexlai@hc4nas02:~/docsify_proj/quickstart$ ls -l
total 4
-rw-rw-r-- 1 alexlai alexlai 256 Jun  8 08:41 package.json
alexlai@hc4nas02:~/docsify_proj/quickstart$ cat package.json 
{
  "name": "quickstart",
  "version": "1.0.0",
  "description": "docsify quickstart guide",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "alexlai@h2Jammy.yushei.net",
  "license": "ISC"
}

¶ 2. install docsify-cli

npm i docsify-cli -g -- > install globally

alexlai@hc4nas02:~/docsify_proj/quickstart$ npm list
quickstart@1.0.0 /home/alexlai/docsify_proj/quickstart
└── (empty)

alexlai@hc4nas02:~/docsify_proj/quickstart$ npm list -g
/home/alexlai/.local/share/fnm/node-versions/v20.14.0/installation/lib
├── corepack@0.28.1
└── npm@10.8.1

2.01. install locally

alexlai@hc4nas02:~/docsify_proj/quickstart$ npm i docsify-cli
npm warn deprecated docsify-server-renderer@4.13.1: docsify-server-renderer 4.x and below is no longer supported while we investigate the future of SSR and SSG for Docsify

added 204 packages, and audited 205 packages in 45s

17 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (7 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
alexlai@hc4nas02:~/docsify_proj/quickstart$ npm list
quickstart@1.0.0 /home/alexlai/docsify_proj/quickstart
└── docsify-cli@4.4.4

server-side rendering (SSR) and static site generation (SSG) for Docsify. https://github.com/docsifyjs/docsify/releases watch out for new release

alexlai@hc4nas02:~/docsify_proj/quickstart$ npm audit fix

up to date, audited 205 packages in 9s

17 packages are looking for funding
  run `npm fund` for details

# npm audit report

got  <11.8.5
Severity: moderate
Got allows a redirect to a UNIX socket - https://github.com/advisories/GHSA-pfrx-2q88-qq97
fix available via `npm audit fix --force`
Will install docsify-cli@4.4.2, which is a breaking change
node_modules/got
  package-json  <=6.5.0
  Depends on vulnerable versions of got
  node_modules/package-json
    latest-version  0.2.0 - 5.1.0
    Depends on vulnerable versions of package-json
    node_modules/latest-version
      update-notifier  0.2.0 - 5.1.0
      Depends on vulnerable versions of latest-version
      node_modules/update-notifier
        docsify-cli  >=1.1.0
        Depends on vulnerable versions of docsify
        Depends on vulnerable versions of update-notifier
        node_modules/docsify-cli

marked  <=4.0.9
Severity: high
Regular Expression Denial of Service (REDoS) in Marked - https://github.com/advisories/GHSA-4r62-v4vq-hr96
Inefficient Regular Expression Complexity in marked - https://github.com/advisories/GHSA-rrrm-qjm4-v8hf
Inefficient Regular Expression Complexity in marked - https://github.com/advisories/GHSA-5v2h-r2cx-5xgj
fix available via `npm audit fix --force`
Will install docsify-cli@4.4.2, which is a breaking change
node_modules/marked
  docsify  >=4.11.5
  Depends on vulnerable versions of marked
  node_modules/docsify
    docsify-server-renderer  >=4.12.0
    Depends on vulnerable versions of docsify
    node_modules/docsify-server-renderer

8 vulnerabilities (7 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force
alexlai@hc4nas02:~/docsify_proj/quickstart$ npm audit fix --force
npm warn using --force Recommended protections disabled.
npm warn audit Updating docsify-cli to 4.4.2, which is a SemVer major change.

added 15 packages, removed 4 packages, changed 9 packages, and audited 216 packages in 11s

17 packages are looking for funding
  run `npm fund` for details

# npm audit report

got  <11.8.5
Severity: moderate
Got allows a redirect to a UNIX socket - https://github.com/advisories/GHSA-pfrx-2q88-qq97
fix available via `npm audit fix --force`
Will install docsify-cli@1.0.0, which is a breaking change
node_modules/got
  package-json  <=6.5.0
  Depends on vulnerable versions of got
  node_modules/package-json
    latest-version  0.2.0 - 5.1.0
    Depends on vulnerable versions of package-json
    node_modules/latest-version
      update-notifier  0.2.0 - 5.1.0
      Depends on vulnerable versions of latest-version
      node_modules/update-notifier
        docsify-cli  >=1.1.0
        Depends on vulnerable versions of update-notifier
        node_modules/docsify-cli

marked  <=4.0.9
Severity: high
Regular Expression Denial of Service (REDoS) in Marked - https://github.com/advisories/GHSA-4r62-v4vq-hr96
Inefficient Regular Expression Complexity in marked - https://github.com/advisories/GHSA-rrrm-qjm4-v8hf
Inefficient Regular Expression Complexity in marked - https://github.com/advisories/GHSA-5v2h-r2cx-5xgj
fix available via `npm audit fix`
node_modules/marked
  docsify  >=4.11.5
  Depends on vulnerable versions of marked
  node_modules/docsify
    docsify-server-renderer  >=4.12.0
    Depends on vulnerable versions of docsify
    node_modules/docsify-server-renderer

8 vulnerabilities (7 moderate, 1 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

2.02. Initialize If you want to write the documentation in the ./docs subdirectory, you can use the init command.

if installed locally npx is a tool that comes with npm (since version 5.2.0) that allows you to run locally installed npm packages without having to reference their full paths.

alexlai@hc4nas02:~/docsify_proj/quickstart$ npx docsify init ./docs

Initialization succeeded! Please run docsify serve ./docs

alexlai@hc4nas02:~/docsify_proj/quickstart$ ls -l
total 104
drwxrwxr-x   2 alexlai alexlai    58 Jun  8 09:54 docs
drwxrwxr-x 177 alexlai alexlai  8192 Jun  8 09:38 node_modules
-rw-rw-r--   1 alexlai alexlai   309 Jun  8 09:38 package.json
-rw-rw-r--   1 alexlai alexlai 86270 Jun  8 09:38 package-lock.json
alexlai@hc4nas02:~/docsify_proj/quickstart$ ls -l ./docs/
total 8
-rw-rw-r-- 1 alexlai alexlai 604 Jun  8 09:54 index.html
-rw-rw-r-- 1 alexlai alexlai  34 Jun  8 09:38 README.md

alexlai@hc4nas02:~/docsify_proj/quickstart$ npx docsify serve ./docs

Serving /home/alexlai/docsify_proj/quickstart/docs now.
Listening at http://localhost:3000

docsify serve you can not change localhost!!

alexlai@hc4nas02:~/docsify_proj/quickstart$ npx docsify serve --help
docsify serve [path]

Run local server to preview site.

Global Options
  --help, -h     Show help                                             [boolean]
  --version, -v  Show version number                                   [boolean]

Options:
  --open, -o             Open docs in default browser. To explicitly set --open
                         to false you may use --no-open.
                                                      [boolean] [default: false]
  --port, -p             Listen port.                   [number] [default: 3000]
  --livereload-port, -P  livereload Listen port.       [number] [default: 35729]
  --index-name, -i       Custom filename instead of index.html to serve by
                         default                                        [string]

use pythn3

alexlai@hc4nas02:~/docsify_proj/quickstart/docs$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
192.168.48.133 - - [08/Jun/2024 10:08:23] "GET / HTTP/1.1" 200 -
192.168.48.133 - - [08/Jun/2024 10:08:23] "GET /README.md HTTP/1.1" 200 -

docsify-01.png