Gathering detailed insights and metrics for create-index-ts
Gathering detailed insights and metrics for create-index-ts
Gathering detailed insights and metrics for create-index-ts
Gathering detailed insights and metrics for create-index-ts
create-ts-index
Automatic create index.ts file
ts-create-index
Creates Typescript ./index.ts file in target directories that imports and exports all sibling files and directories.
@nabh/create-index-ts
Utility to create an index.ts file that exports all Typescript modules in a directory
create-react-ts-component
Create React functional component directory with index file and imported styles
npm install create-index-ts
Typescript
Module System
Min. Node Version
Node Version
NPM Version
65.3
Supply Chain
96.2
Quality
72.1
Maintenance
50
Vulnerability
97.9
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
68 Commits
10 Branches
7 Contributors
Updated on Jul 01, 2019
Latest Version
1.2.0
Package Id
create-index-ts@1.2.0
Unpacked Size
58.65 kB
Size
14.56 kB
File Count
31
NPM Version
6.4.1
Node Version
10.13.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
create-index-normalized
program creates (and maintains) ES6 ./index.js
file in target directories that imports and exports sibling files and directories.
This forked version of create-index
normalizes filenames with dashes since exports cannot have dashes (see #8)
1> tree ./ 2./ 3├── bar.js 4└── foo.js 5 60 directories, 2 files 7 8> create-index ./ 9[13:17:34] Target directories [ './' ] 10[13:17:34] Update index: false 11[13:17:34] ./index.js [created index] 12[13:17:34] Done 13 14> tree 15. 16├── bar.js 17├── foo.js 18└── index.js 19 200 directories, 3 files
This created index.js
with:
1// @create-index 2 3export { default as bar } from './bar.js'; 4export { default as foo } from './foo.js'; 5
Lets create a new file and re-run create-index
:
1> touch baz.js 2> tree ./ 3./ 4├── bar.js 5├── baz.js 6├── foo.js 7└── index.js 8 90 directories, 4 files 10 11> create-index ./ 12[13:21:55] Target directories [ './' ] 13[13:21:55] Update index: false 14[13:21:55] ./index.js [updated index] 15[13:21:55] Done
This have updated index.js
file:
1// @create-index 2 3export { default as bar } from './bar.js'; 4export { default as baz } from './baz.js'; 5export { default as foo } from './foo.js'; 6
1npm install create-index 2 3create-index --help 4 5Options: 6 --recursive, -r Create/update index files recursively. Halts on any 7 unsafe "index.js" files. [boolean] [default: false] 8 --ignoreUnsafe, -i Ignores unsafe "index.js" files instead of halting. 9 [boolean] [default: false] 10 --ignoreDirectories, -d Ignores importing directories into the index file, 11 even if they have a safe "index.js". 12 [boolean] [default: false] 13 --update, -u Updates only previously created index files 14 (recursively). [boolean] [default: false] 15 --banner Add a custom banner at the top of the index file 16 [string] 17 --extensions, -x Allows some extensions to be parsed as valid source. 18 First extension will always be preferred to homonyms 19 with another allowed extension. 20 [array] [default: ["js"]] 21 22Examples: 23 create-index ./src ./src/utilities Creates or updates an existing 24 create-index index file in the target 25 (./src, ./src/utilities) directories. 26 create-index --update ./src ./tests Finds all create-index index files in 27 the target directories and descending 28 directories. Updates found index 29 files. 30 create-index ./src --extensions js jsx Creates or updates an existing 31 create-index index file in the target 32 (./src) directory for both .js and 33 .jsx extensions.
create-index
Programmatically1import { 2 writeIndex 3} from 'create-index'; 4 5/** 6 * @type {Function} 7 * @param {Array<string>} directoryPaths 8 * @throws {Error} Directory "..." does not exist. 9 * @throws {Error} "..." is not a directory. 10 * @throws {Error} "..." unsafe index. 11 * @returns {boolean} 12 */ 13writeIndex;
Note that the writeIndex
function is synchronous.
1import { 2 findIndexFiles 3} from 'create-index'; 4 5/** 6 * @type {Function} 7 * @param {string} directoryPath 8 * @returns {Array<string>} List of directory paths that have create-index index file. 9 */ 10findIndexFiles;
Since Gulp can ran arbitrary JavaScript code, there is no need for a separate plugin. See Using create-index
Programmatically.
1import { 2 writeIndex 3} from 'create-index'; 4 5gulp.task('create-index', () => { 6 writeIndex(['./target_directory']); 7});
Note that the writeIndex
function is synchronous.
create-index
program will look into the target directory.
If there is no ./index.js
, it will create a new file, e.g.
1// @create-index
Created index file must start with // @create-index\n\n
. This is used to make sure that create-index
does not accidentally overwrite your local files.
If there are sibling files, index file will import
them and export
, e.g.
1children-directories-and-files git:(master) ✗ ls -lah 2total 0 3drwxr-xr-x 5 gajus staff 170B 6 Jan 15:39 . 4drwxr-xr-x 10 gajus staff 340B 6 Jan 15:53 .. 5drwxr-xr-x 2 gajus staff 68B 6 Jan 15:29 bar 6drwxr-xr-x 2 gajus staff 68B 6 Jan 15:29 foo 7-rw-r--r-- 1 gajus staff 0B 6 Jan 15:29 foo.js
Given the above directory contents, ./index.js
will be:
1// @create-index 2 3import { default as bar } from './bar'; 4import { default as foo } from './foo.js'; 5 6export { 7 bar, 8 foo 9};
When file has the same name as a sibling directory, file import
takes precedence.
Directories that do not have ./index.js
in themselves will be excluded.
When run again, create-index
will update existing ./index.js
if it starts with // @create-index\n\n
.
If create-index
is executed against a directory that contains ./index.js
, which does not start with // @create-index\n\n
, an error will be thrown.
--update
create-index
can ignore files in a directory if ./index.js
contains special object with defined ignore
property which takes an array
of regular expressions
defined as strings
, e.g.
1> cat index.js 2// @create-index {"ignore": ["/baz.js$/"]}
1> tree ./ 2./ 3├── bar.js 4├── baz.js 5├── foo.js 6└── index.js 7 80 directories, 4 files
Given the above directory contents, after running create-index
with --update
flag, ./index.js
will be:
1// @create-index {"ignore": ["/baz.js$/"]} 2 3import { default as bar } from './bar.js'; 4import { default as foo } from './foo.js'; 5 6export { 7 bar, 8 foo 9};
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
60 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More