Skip to content

Commit 8316ec7

Browse files
committed
v1.0.0
1 parent 572bcbd commit 8316ec7

File tree

6 files changed

+548
-0
lines changed

6 files changed

+548
-0
lines changed

.gitignore

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
/CVS/*
2+
**/CVS/*
3+
.cvsignore
4+
*/.cvsignore
5+
6+
7+
8+
*.patch
9+
*.diff
10+
11+
12+
13+
*~
14+
15+
# temporary files which can be created if a process still has a handle open of a deleted file
16+
.fuse_hidden*
17+
18+
# KDE directory preferences
19+
.directory
20+
21+
# Linux trash folder which might appear on any partition or disk
22+
.Trash-*
23+
24+
# .nfs files are created when an open file is removed but is still being accessed
25+
.nfs*
26+
27+
28+
29+
# Logs
30+
logs
31+
*.log
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
lerna-debug.log*
36+
.pnpm-debug.log*
37+
38+
# Diagnostic reports (https://nodejs.org/api/report.html)
39+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
40+
41+
# Runtime data
42+
pids
43+
*.pid
44+
*.seed
45+
*.pid.lock
46+
47+
# Directory for instrumented libs generated by jscoverage/JSCover
48+
lib-cov
49+
50+
# Coverage directory used by tools like istanbul
51+
coverage
52+
*.lcov
53+
54+
# nyc test coverage
55+
.nyc_output
56+
57+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
58+
.grunt
59+
60+
# Bower dependency directory (https://bower.io/)
61+
bower_components
62+
63+
# node-waf configuration
64+
.lock-wscript
65+
66+
# Compiled binary addons (https://nodejs.org/api/addons.html)
67+
build/Release
68+
69+
# Dependency directories
70+
node_modules/
71+
jspm_packages/
72+
73+
# Snowpack dependency directory (https://snowpack.dev/)
74+
web_modules/
75+
76+
# TypeScript cache
77+
*.tsbuildinfo
78+
79+
# Optional npm cache directory
80+
.npm
81+
82+
# Optional eslint cache
83+
.eslintcache
84+
85+
# Optional stylelint cache
86+
.stylelintcache
87+
88+
# Microbundle cache
89+
.rpt2_cache/
90+
.rts2_cache_cjs/
91+
.rts2_cache_es/
92+
.rts2_cache_umd/
93+
94+
# Optional REPL history
95+
.node_repl_history
96+
97+
# Output of 'npm pack'
98+
*.tgz
99+
100+
# Yarn Integrity file
101+
.yarn-integrity
102+
103+
# dotenv environment variables file
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
.cache
111+
.parcel-cache
112+
113+
# Next.js build output
114+
.next
115+
out
116+
117+
# Nuxt.js build / generate output
118+
.nuxt
119+
dist
120+
121+
# Gatsby files
122+
.cache/
123+
# Comment in the public line in if your project uses Gatsby and not Next.js
124+
# https://nextjs.org/blog/next-9-1#public-directory-support
125+
# public
126+
127+
# vuepress build output
128+
.vuepress/dist
129+
130+
# vuepress v2.x temp and cache directory
131+
.temp
132+
.cache
133+
134+
# Serverless directories
135+
.serverless/
136+
137+
# FuseBox cache
138+
.fusebox/
139+
140+
# DynamoDB Local files
141+
.dynamodb/
142+
143+
# TernJS port file
144+
.tern-port
145+
146+
# Stores VSCode versions used for testing VSCode extensions
147+
.vscode-test
148+
149+
# yarn v2
150+
.yarn/cache
151+
.yarn/unplugged
152+
.yarn/build-state.yml
153+
.yarn/install-state.gz
154+
.pnp.*
155+
156+
157+
158+
# Cache files for Sublime Text
159+
*.tmlanguage.cache
160+
*.tmPreferences.cache
161+
*.stTheme.cache
162+
163+
# Workspace files are user-specific
164+
*.sublime-workspace
165+
166+
# Project files should be checked into the repository, unless a significant
167+
# proportion of contributors will probably not be using Sublime Text
168+
# *.sublime-project
169+
170+
# SFTP configuration file
171+
sftp-config.json
172+
sftp-config-alt*.json
173+
174+
# Package control specific files
175+
Package Control.last-run
176+
Package Control.ca-list
177+
Package Control.ca-bundle
178+
Package Control.system-ca-bundle
179+
Package Control.cache/
180+
Package Control.ca-certs/
181+
Package Control.merged-ca-bundle
182+
Package Control.user-ca-bundle
183+
oscrypto-ca-bundle.crt
184+
bh_unicode_properties.cache
185+
186+
# Sublime-github package stores a github token in this file
187+
# https://packagecontrol.io/packages/sublime-github
188+
GitHub.sublime-settings
189+
190+
191+
192+
# Project-level settings
193+
/.tgitconfig
194+
195+
196+
197+
# Swap
198+
[._]*.s[a-v][a-z]
199+
!*.svg # comment out if you don't need vector files
200+
[._]*.sw[a-p]
201+
[._]s[a-rt-v][a-z]
202+
[._]ss[a-gi-z]
203+
[._]sw[a-p]
204+
205+
# Session
206+
Session.vim
207+
Sessionx.vim
208+
209+
# Temporary
210+
.netrwhist
211+
*~
212+
# Auto-generated tag files
213+
tags
214+
# Persistent undo
215+
[._]*.un~
216+
217+
218+
219+
.vscode/*
220+
!.vscode/settings.json
221+
!.vscode/tasks.json
222+
!.vscode/launch.json
223+
!.vscode/extensions.json
224+
*.code-workspace
225+
226+
# Local History for Visual Studio Code
227+
.history/
228+
229+
230+
231+
# Windows thumbnail cache files
232+
Thumbs.db
233+
Thumbs.db:encryptable
234+
ehthumbs.db
235+
ehthumbs_vista.db
236+
237+
# Dump file
238+
*.stackdump
239+
240+
# Folder config file
241+
[Dd]esktop.ini
242+
243+
# Recycle Bin used on file shares
244+
$RECYCLE.BIN/
245+
246+
# Windows Installer files
247+
*.cab
248+
*.msi
249+
*.msix
250+
*.msm
251+
*.msp
252+
253+
# Windows shortcuts
254+
*.lnk
255+
256+
257+
258+
# General
259+
.DS_Store
260+
.AppleDouble
261+
.LSOverride
262+
263+
# Icon must end with two \r
264+
Icon
265+
266+
# Thumbnails
267+
._*
268+
269+
# Files that might appear in the root of a volume
270+
.DocumentRevisions-V100
271+
.fseventsd
272+
.Spotlight-V100
273+
.TemporaryItems
274+
.Trashes
275+
.VolumeIcon.icns
276+
.com.apple.timemachine.donotpresent
277+
278+
# Directories potentially created on remote AFP share
279+
.AppleDB
280+
.AppleDesktop
281+
Network Trash Folder
282+
Temporary Items
283+
.apdisk
284+
© 2021 GitHub, Inc.
285+
Terms

.npmrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
depth=0
2+
loglevel=notice
3+
engine-strict=true
4+
fetch-retries=3
5+
fetch-retry-mintimeout=5
6+
save=true
7+
8+
package-lock=true
9+
10+
scope=@iyowei
11+
@iyowei:registry="https://registry.npmjs.org/"
12+
13+
registry="https://registry.npmmirror.com"

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
[precinct]: https://github.com/dependents/node-precinct
2+
3+
# jsModuleDependenciesToBeInstalled(specifiers)
4+
5+
> JavaScript 模块(esm, cjs, amd, ts, tsx, jsx)说明符过滤器:需要额外安装的的模块。
6+
7+
依赖(说明符)收集器,见 [Precinct][precinct]
8+
9+
## 使用
10+
11+
- specifiers {Array} [Precinct][precinct] 收集器收集到的模块说明符集合,默认 **`[]`**
12+
- 返回 {Array} 需要额外安装的的模块名称。
13+
14+
```js
15+
import { readFileSync } from "fs";
16+
import { log } from "console";
17+
18+
import precinct from "detective-es6";
19+
import jsModuleDependenciesToBeInstalled from "@iyowei/js-module-dependencies-to-be-installed";
20+
21+
/**
22+
* "/Users/iyowei/Development/iyowei/create-esm/cli.js" 片段,
23+
*
24+
* import { existsSync } from "fs";
25+
* import { Listr } from "listr2";
26+
* import shell from "shelljs";
27+
* import meow from "meow";
28+
* import chalk from "chalk";
29+
* import { banner, mainHelp, setupHelp, COMMAND_SET, COMMAND_DEFAULTS, getReport } from "./src/messages.js";
30+
* import pressAnyKeyToContinue from "./src/pressAnyKeyToContinue.js";
31+
* import { updateGlobalConfigurations, getGlobalConfigurations } from "./src/options/global.js";
32+
* import makeOptions from "./src/options/make.js";
33+
* import prerequisites from "./src/prerequisites.js";
34+
*/
35+
const specifiers = precinct(
36+
readFileSync("/Users/iyowei/Development/iyowei/create-esm/cli.js", "utf-8")
37+
);
38+
39+
const read = jsModuleDependenciesToBeInstalled(specifiers);
40+
console.log("read", read);
41+
// read: [ 'listr2', 'shelljs', 'meow', 'chalk' ]
42+
43+
const given = jsModuleDependenciesToBeInstalled([
44+
"./startup.js",
45+
"../config.mjs",
46+
47+
"file:///opt/nodejs/config.js",
48+
49+
"/opt/nodejs/config.mjs",
50+
51+
"fs",
52+
"node:fs",
53+
"node:fs/promise",
54+
55+
"some-package",
56+
57+
"@others/test",
58+
"@npmcli/package-json",
59+
60+
"@npmcli/package-json/promise",
61+
"some-package/lib/shuffle.mjs",
62+
]);
63+
console.log("given", given);
64+
// given: given [ 'some-package', '@others/test', '@npmcli/package-json' ]
65+
```
66+
67+
## 安装
68+
69+
[![Node version](https://img.shields.io/badge/node.js-%3E%3D12.20.0-brightgreen?style=flat&logo=Node.js)](https://nodejs.org/en/download/)
70+
71+
```shell
72+
# Pnpm
73+
pnpm add @iyowei/js-module-dependencies-to-be-installed
74+
75+
# yarn
76+
yarn add @iyowei/js-module-dependencies-to-be-installed
77+
78+
# npm
79+
npm add @iyowei/js-module-dependencies-to-be-installed
80+
```
81+
82+
## 设计
83+
84+
ESM, CJS, AMD, TS, TSX, JSX,等等,模块定义很多,对应了不同依赖(说明符)收集器,但说明符规范是一致的,所以将过滤器部分提取出来,方便复用。
85+
86+
## 参与贡献
87+
88+
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)

0 commit comments

Comments
 (0)