eject 0.3.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +9 -0
- package/.prettierrc +5 -0
- package/CHANGELOG.md +4 -0
- package/README.md +11 -67
- package/bin-entry.js +3 -0
- package/package.json +44 -32
- package/src/command.ts +66 -0
- package/src/config.ts +5 -0
- package/src/git.ts +29 -0
- package/src/index.ts +24 -0
- package/src/log.ts +17 -0
- package/src/system.ts +101 -0
- package/tests/system.spec.ts +7 -0
- package/tsconfig.json +113 -0
- package/LICENSE +0 -21
- package/Makefile +0 -6
- package/eject.js +0 -52
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,75 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
[](https://codecov.io/gh/bigeasy/eject)
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
1
|
+
# Eject
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
This package is written to help you to eject your project from the current repository. It will copy all the files and folders to `ejected` folder and remove it from node_modules.
|
|
6
4
|
|
|
7
|
-
| What | Where |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| Discussion | https://github.com/bigeasy/eject/issues/1 |
|
|
10
|
-
| Documentation | https://bigeasy.github.io/eject |
|
|
11
|
-
| Source | https://github.com/bigeasy/eject |
|
|
12
|
-
| Issues | https://github.com/bigeasy/eject/issues |
|
|
13
|
-
| CI | https://travis-ci.org/bigeasy/eject |
|
|
14
|
-
| Coverage: | https://codecov.io/gh/bigeasy/eject |
|
|
15
|
-
| License: | MIT |
|
|
16
|
-
|
|
17
|
-
Eject installs from NPM.
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
npm install eject
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Overview
|
|
24
|
-
|
|
25
|
-
Extant is an implementation of SQL's COALESCE that I've used for some time to
|
|
26
|
-
deal with the fact that JavaScript truthiness will treat `''` and `0` as true so
|
|
27
|
-
the `||` operator can't always be used to create given or default one-liner.
|
|
28
|
-
|
|
29
|
-
```javascript
|
|
30
|
-
const { compare, raise, equal } = require('eject')
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
We use the name "extant" on NPM because we want the first extant argument.
|
|
34
|
-
|
|
35
|
-
## Living `README.md`
|
|
36
|
-
|
|
37
|
-
This `README.md` is also a unit test using the
|
|
38
|
-
[Proof](https://github.com/bigeasy/proof) unit test framework. We'll use the
|
|
39
|
-
Proof `okay` function to assert out statements in the readme. A Proof unit test
|
|
40
|
-
generally looks like this.
|
|
41
|
-
|
|
42
|
-
```javascript
|
|
43
|
-
require('proof')(4, async okay => {
|
|
44
|
-
okay('always okay')
|
|
45
|
-
okay(true, 'okay if true')
|
|
46
|
-
okay(1, 1, 'okay if equal')
|
|
47
|
-
okay({ value: 1 }, { value: 1 }, 'okay if deep strict equal')
|
|
48
|
-
})
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
You can run this unit test yourself to see the output from the various
|
|
52
|
-
code sections of the readme.
|
|
53
|
-
|
|
54
|
-
```text
|
|
55
|
-
git clone git@github.com:bigeasy/eject.git
|
|
56
|
-
cd eject
|
|
57
|
-
npm install --no-package-lock --no-save
|
|
58
|
-
node test/readme.t.js
|
|
59
|
-
```
|
|
60
5
|
|
|
61
6
|
## Usage
|
|
62
7
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```javascript
|
|
66
|
-
const { compare, raise, equal } = require('depature')
|
|
8
|
+
```bash
|
|
9
|
+
npx eject <dependency>
|
|
67
10
|
```
|
|
68
11
|
|
|
69
|
-
|
|
70
|
-
that is the first value that is not `== null`, which would be `null` or
|
|
71
|
-
`undefined`. If there is no such argument it returns `null`.
|
|
12
|
+
## Dev Usage
|
|
72
13
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
14
|
+
1. Clone the repository
|
|
15
|
+
2. Run `npm install`
|
|
16
|
+
2. Run `npm build`
|
|
17
|
+
3. Run `npm link`
|
|
18
|
+
|
|
19
|
+
Now you can use `npx eject <dependency>` to eject the dependency from any other project.
|
package/bin-entry.js
ADDED
package/package.json
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "eject",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "This package helps you to eject dependencies from node_modules easily",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/snake-py/eject.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"cli"
|
|
13
|
+
],
|
|
14
|
+
"author": "snake-py",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/snake-py/eject/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/snake-py/eject#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"cac": "^6.7.14",
|
|
22
|
+
"chalk": "^5.3.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@brillout/release-me": "^0.4.2",
|
|
26
|
+
"@types/node": "^22.9.0",
|
|
27
|
+
"prettier": "^3.3.3",
|
|
28
|
+
"typescript": "^5.6.3",
|
|
29
|
+
"vitest": "^2.1.4"
|
|
30
|
+
},
|
|
31
|
+
"bin": {
|
|
32
|
+
"eject": "./bin-entry.js",
|
|
33
|
+
"ejectjs": "./bin-entry.js"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"dev": "tsc --watch",
|
|
38
|
+
"test": "vitest",
|
|
39
|
+
"format": "prettier --write .",
|
|
40
|
+
"release": "release-me patch",
|
|
41
|
+
"release:minor": "release-me minor",
|
|
42
|
+
"release:major": "release-me major",
|
|
43
|
+
"release:commit": "release-me commit"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/command.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { config } from './config.js';
|
|
3
|
+
import {
|
|
4
|
+
amendCommit,
|
|
5
|
+
commitEjection,
|
|
6
|
+
isGitHistoryClean,
|
|
7
|
+
isGitInstalled,
|
|
8
|
+
} from './git.js';
|
|
9
|
+
import { errorLog, infoLog, warnLog } from './log.js';
|
|
10
|
+
import { copyDependency, install, updatePackageJson } from './system.js';
|
|
11
|
+
|
|
12
|
+
export function eject(
|
|
13
|
+
dependencies: string[],
|
|
14
|
+
options: { force: boolean; verbose: boolean },
|
|
15
|
+
) {
|
|
16
|
+
if (!options.force && !isGitInstalled()) {
|
|
17
|
+
warnLog(
|
|
18
|
+
'Git is not installed, please install git or use --force to bypass git check',
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!options.force && !isGitHistoryClean()) {
|
|
23
|
+
warnLog(
|
|
24
|
+
'Please commit your changes before ejecting dependencies or use --force to bypass git history',
|
|
25
|
+
);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const successFullEjections = [];
|
|
29
|
+
const failedEjections = [];
|
|
30
|
+
for (const dependency of dependencies) {
|
|
31
|
+
try {
|
|
32
|
+
copyDependency(dependency);
|
|
33
|
+
successFullEjections.push(dependency);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (options.verbose) {
|
|
36
|
+
errorLog('Error ejecting dependency:', dependency);
|
|
37
|
+
}
|
|
38
|
+
failedEjections.push(dependency);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (successFullEjections.length > 0) {
|
|
42
|
+
console.log(
|
|
43
|
+
'✅ Ejected dependencies:',
|
|
44
|
+
chalk.bold(successFullEjections),
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
warnLog('No dependencies ejected');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (failedEjections.length > 0) {
|
|
51
|
+
console.log('❌ Ejected dependencies: ', chalk.bold(failedEjections));
|
|
52
|
+
}
|
|
53
|
+
updatePackageJson(successFullEjections);
|
|
54
|
+
commitEjection(config.COMMIT_MESSAGE);
|
|
55
|
+
console.log(
|
|
56
|
+
`📦 Installing dependencies (you can skip this e.g. with ${chalk.bold('Ctrl + C')})`,
|
|
57
|
+
);
|
|
58
|
+
install();
|
|
59
|
+
console.log('✅ Install done');
|
|
60
|
+
amendCommit();
|
|
61
|
+
console.log(
|
|
62
|
+
'➡️ Run',
|
|
63
|
+
chalk.bold('git show HEAD'),
|
|
64
|
+
'to see the ejected code',
|
|
65
|
+
);
|
|
66
|
+
}
|
package/src/config.ts
ADDED
package/src/git.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
|
|
3
|
+
export function commitEjection(commitMessage: string = 'Eject dependencies') {
|
|
4
|
+
execSync('git add .');
|
|
5
|
+
execSync(`git commit -m "${commitMessage}"`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function amendCommit() {
|
|
9
|
+
execSync('git add -A');
|
|
10
|
+
execSync(`git commit --amend --no-edit`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isGitInstalled() {
|
|
14
|
+
try {
|
|
15
|
+
execSync('git --version');
|
|
16
|
+
return true;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isGitHistoryClean() {
|
|
23
|
+
try {
|
|
24
|
+
execSync('git diff --exit-code');
|
|
25
|
+
return true;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { cac } from 'cac';
|
|
2
|
+
|
|
3
|
+
import { eject } from './command.js';
|
|
4
|
+
import { config } from './config.js';
|
|
5
|
+
|
|
6
|
+
const cli = cac('eject');
|
|
7
|
+
|
|
8
|
+
cli.command('[...dependencies]', 'Ejects a dependency from node_modules', {
|
|
9
|
+
allowUnknownOptions: true,
|
|
10
|
+
})
|
|
11
|
+
.option('-f, --force', 'Bypass git history check')
|
|
12
|
+
.option('-v, --verbose', 'Verbose output')
|
|
13
|
+
.action(eject);
|
|
14
|
+
|
|
15
|
+
cli.help();
|
|
16
|
+
cli.version(config.projectVersion);
|
|
17
|
+
|
|
18
|
+
cli.parse(
|
|
19
|
+
process.argv.length === 2 ? [...process.argv, '--help'] : process.argv,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
process.on('unhandledRejection', (rejectValue) => {
|
|
23
|
+
throw rejectValue;
|
|
24
|
+
});
|
package/src/log.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export function successLog(message?: unknown, ...optionalParams: unknown[]) {
|
|
4
|
+
console.log(chalk.green(message, optionalParams));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function errorLog(message?: unknown, ...optionalParams: unknown[]) {
|
|
8
|
+
console.log(chalk.red(message, optionalParams));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function infoLog(message?: unknown, ...optionalParams: unknown[]) {
|
|
12
|
+
console.log(chalk.blue(message, optionalParams));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function warnLog(message?: unknown, ...optionalParams: unknown[]) {
|
|
16
|
+
console.log(chalk.yellow(message, optionalParams));
|
|
17
|
+
}
|
package/src/system.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
export function updatePackageJson(successFullEjections: string[]) {
|
|
6
|
+
const packageJson = JSON.parse(
|
|
7
|
+
fs.readFileSync(resolve('./package.json'), 'utf-8'),
|
|
8
|
+
);
|
|
9
|
+
packageJson['devDependencies'] = setPathAsVersion(
|
|
10
|
+
packageJson['devDependencies'],
|
|
11
|
+
successFullEjections,
|
|
12
|
+
);
|
|
13
|
+
packageJson['dependencies'] = setPathAsVersion(
|
|
14
|
+
packageJson['dependencies'],
|
|
15
|
+
successFullEjections,
|
|
16
|
+
);
|
|
17
|
+
fs.writeFileSync(
|
|
18
|
+
resolve('./package.json'),
|
|
19
|
+
JSON.stringify(packageJson, null, 2),
|
|
20
|
+
);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function setPathAsVersion(
|
|
25
|
+
dependencies: Record<string, string>,
|
|
26
|
+
successFullEjections: string[],
|
|
27
|
+
) {
|
|
28
|
+
const updatedDependencies: Record<string, string> = {};
|
|
29
|
+
for (const key in dependencies) {
|
|
30
|
+
if (!successFullEjections.includes(key)) {
|
|
31
|
+
updatedDependencies[key] = dependencies[key] as string;
|
|
32
|
+
} else {
|
|
33
|
+
updatedDependencies[key] = `file:./ejected/${key}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return updatedDependencies;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function copyDependency(dependency: string) {
|
|
40
|
+
const dependencyPath = resolve('./node_modules', dependency);
|
|
41
|
+
if (!fs.existsSync(dependencyPath)) {
|
|
42
|
+
throw new Error('Dependency not found in node_modules');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!fs.existsSync('./ejected')) {
|
|
46
|
+
fs.mkdirSync('./ejected');
|
|
47
|
+
}
|
|
48
|
+
if (fs.existsSync(resolve('./ejected', dependency))) {
|
|
49
|
+
throw new Error('Dependency already ejected');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fs.cpSync(dependencyPath, resolve('./ejected', dependency), {
|
|
53
|
+
recursive: true,
|
|
54
|
+
force: true,
|
|
55
|
+
dereference: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function install() {
|
|
60
|
+
const packageManager = detectPackageManager();
|
|
61
|
+
execSync(`${packageManager} install`, { stdio: 'inherit' });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const detectPackageManager = (currentDir: string = './', depth: number = 0) => {
|
|
65
|
+
if (depth > 20) {
|
|
66
|
+
throw new Error('No lock file found');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// scan for lock files
|
|
70
|
+
const lockFiles = [
|
|
71
|
+
'yarn.lock',
|
|
72
|
+
'package-lock.json',
|
|
73
|
+
'pnpm-lock.yaml',
|
|
74
|
+
'bun.lock',
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const foundLockFiles = lockFiles.filter((lockFile) =>
|
|
78
|
+
fs.existsSync(resolve(currentDir, lockFile)),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (foundLockFiles.length === 0) {
|
|
82
|
+
return detectPackageManager(resolve(currentDir, '..'), depth + 1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (foundLockFiles.length > 1) {
|
|
86
|
+
throw new Error('Multiple lock files found');
|
|
87
|
+
}
|
|
88
|
+
const foundLock = foundLockFiles[0] as string;
|
|
89
|
+
|
|
90
|
+
if (foundLock === 'yarn.lock') {
|
|
91
|
+
return 'yarn';
|
|
92
|
+
} else if (foundLock === 'package-lock.json') {
|
|
93
|
+
return 'npm';
|
|
94
|
+
} else if (foundLock === 'pnpm-lock.yaml') {
|
|
95
|
+
return 'pnpm';
|
|
96
|
+
} else if (foundLock === 'bun.lock') {
|
|
97
|
+
return 'bun';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
throw new Error('Unknown lock file');
|
|
101
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
+
"lib": [
|
|
16
|
+
"ES2021"
|
|
17
|
+
] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
|
18
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
19
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
20
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
21
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
22
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
23
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
24
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
25
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
26
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
27
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
28
|
+
|
|
29
|
+
/* Modules */
|
|
30
|
+
"module": "Node16" /* Specify what module code is generated. */,
|
|
31
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
32
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
33
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
34
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
35
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
36
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
37
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
38
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
39
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
40
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
41
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
+
"resolveJsonModule": true /* Enable importing .json files. */,
|
|
45
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
46
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
47
|
+
|
|
48
|
+
/* JavaScript Support */
|
|
49
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
50
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
51
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
52
|
+
|
|
53
|
+
/* Emit */
|
|
54
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
55
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
56
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
57
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
58
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
60
|
+
"outDir": "./dist/esm/" /* Specify an output folder for all emitted files. */,
|
|
61
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
62
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
63
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
64
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
65
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
+
"noEmitOnError": true /* Disable emitting files if any type checking errors are reported. */,
|
|
74
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
77
|
+
|
|
78
|
+
/* Interop Constraints */
|
|
79
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
80
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
81
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
82
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
83
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
84
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
85
|
+
|
|
86
|
+
/* Type Checking */
|
|
87
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
88
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
89
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
90
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
91
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
92
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
93
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
94
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
95
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
96
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
97
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
98
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
99
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
100
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
101
|
+
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
|
|
102
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
103
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
104
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
105
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
106
|
+
|
|
107
|
+
/* Completeness */
|
|
108
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
109
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
110
|
+
},
|
|
111
|
+
"include": ["./src/**/*.ts"],
|
|
112
|
+
"exclude": ["**/*.spec.ts", "./node_modules/", "./dist/"]
|
|
113
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014-2022 Alan Gutierrez
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/Makefile
DELETED
package/eject.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
|
|
3
|
-
class Once {
|
|
4
|
-
constructor ({ ee, events, named }) {
|
|
5
|
-
this.promise = new Promise((resolve, reject) => {
|
|
6
|
-
const listeners = new Map
|
|
7
|
-
function unlisten () {
|
|
8
|
-
for (const [ name, listener ] of listeners) {
|
|
9
|
-
ee.removeListener(name, listener)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
for (const name of events) {
|
|
13
|
-
listeners.set(name, function (...vargs) {
|
|
14
|
-
unlisten()
|
|
15
|
-
if (named) {
|
|
16
|
-
vargs.unshift(name)
|
|
17
|
-
}
|
|
18
|
-
resolve(vargs)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
if (!listeners.has('error')) {
|
|
22
|
-
listeners.set('error', function (error) {
|
|
23
|
-
unlisten()
|
|
24
|
-
reject(error)
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
for (const [ name, listener ] of listeners) {
|
|
28
|
-
ee.on(name, listener)
|
|
29
|
-
}
|
|
30
|
-
this._emit = function (name, vargs) {
|
|
31
|
-
this._emit = () => {}
|
|
32
|
-
listeners.get(name).apply(null, vargs)
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
emit (name, ...vargs) {
|
|
38
|
-
(this._emit)(name, vargs)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.once = function (ee, events) {
|
|
43
|
-
return new Once({
|
|
44
|
-
ee: ee,
|
|
45
|
-
events: Array.isArray(events) ? events : [ events ],
|
|
46
|
-
named: Array.isArray(events)
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
exports.once.NULL = {
|
|
51
|
-
emit: () => {}
|
|
52
|
-
}
|