eject 1.0.0 → 1.0.1
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/CHANGELOG.md +9 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/command.ts +12 -6
- package/src/system.ts +19 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.0.1](https://github.com/snake-py/eject/compare/v1.0.0...v1.0.1) (2024-11-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* use `link:` protocol instead of `file:` ([40cbab3](https://github.com/snake-py/eject/commit/40cbab318c94ebf9953e90ffa4f9b739e0282f80))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
# 1.0.0 (2024-11-15)
|
|
2
11
|
|
|
3
12
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Eject
|
|
2
2
|
|
|
3
|
-
This package is written to
|
|
3
|
+
This package is written to eject dependencies from your project. It will copy all the files and folders to an `ejected` folder and remove it from node_modules. It will automatically update the package.json file an link the dependencies to the ejected folder.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Usage
|
package/package.json
CHANGED
package/src/command.ts
CHANGED
|
@@ -7,7 +7,12 @@ import {
|
|
|
7
7
|
isGitInstalled,
|
|
8
8
|
} from './git.js';
|
|
9
9
|
import { errorLog, infoLog, warnLog } from './log.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
copyDependency,
|
|
12
|
+
detectPackageManager,
|
|
13
|
+
updatePackageJson,
|
|
14
|
+
} from './system.js';
|
|
15
|
+
import { execSync } from 'child_process';
|
|
11
16
|
|
|
12
17
|
export function eject(
|
|
13
18
|
dependencies: string[],
|
|
@@ -52,11 +57,12 @@ export function eject(
|
|
|
52
57
|
}
|
|
53
58
|
updatePackageJson(successFullEjections);
|
|
54
59
|
commitEjection(config.COMMIT_MESSAGE);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
const { packageManager, lockFile } = detectPackageManager();
|
|
61
|
+
const installCmd = `${packageManager} install`;
|
|
62
|
+
const installLog = chalk.bold(installCmd);
|
|
63
|
+
console.log(`📦 Running ${installLog} to update ${chalk.bold(lockFile)}`);
|
|
64
|
+
execSync(installCmd, { stdio: 'inherit' });
|
|
65
|
+
console.log(`✅ ${installLog} done`);
|
|
60
66
|
amendCommit();
|
|
61
67
|
console.log(
|
|
62
68
|
'➡️ Run',
|
package/src/system.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import
|
|
3
|
+
import assert from 'assert';
|
|
4
4
|
|
|
5
5
|
export function updatePackageJson(successFullEjections: string[]) {
|
|
6
6
|
const packageJson = JSON.parse(
|
|
@@ -30,7 +30,7 @@ function setPathAsVersion(
|
|
|
30
30
|
if (!successFullEjections.includes(key)) {
|
|
31
31
|
updatedDependencies[key] = dependencies[key] as string;
|
|
32
32
|
} else {
|
|
33
|
-
updatedDependencies[key] = `
|
|
33
|
+
updatedDependencies[key] = `link:./ejected/${key}`;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
return updatedDependencies;
|
|
@@ -56,12 +56,10 @@ export function copyDependency(dependency: string) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const detectPackageManager = (currentDir: string = './', depth: number = 0) => {
|
|
59
|
+
export function detectPackageManager(
|
|
60
|
+
currentDir: string = './',
|
|
61
|
+
depth: number = 0,
|
|
62
|
+
) {
|
|
65
63
|
if (depth > 20) {
|
|
66
64
|
throw new Error('No lock file found');
|
|
67
65
|
}
|
|
@@ -85,17 +83,18 @@ const detectPackageManager = (currentDir: string = './', depth: number = 0) => {
|
|
|
85
83
|
if (foundLockFiles.length > 1) {
|
|
86
84
|
throw new Error('Multiple lock files found');
|
|
87
85
|
}
|
|
88
|
-
const foundLock = foundLockFiles[0] as string;
|
|
89
86
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} else if (
|
|
95
|
-
|
|
96
|
-
} else if (
|
|
97
|
-
|
|
87
|
+
const lockFile = foundLockFiles[0] as string;
|
|
88
|
+
let packageManager: string | undefined;
|
|
89
|
+
if (lockFile === 'yarn.lock') {
|
|
90
|
+
packageManager = 'yarn';
|
|
91
|
+
} else if (lockFile === 'package-lock.json') {
|
|
92
|
+
packageManager = 'npm';
|
|
93
|
+
} else if (lockFile === 'pnpm-lock.yaml') {
|
|
94
|
+
packageManager = 'pnpm';
|
|
95
|
+
} else if (lockFile === 'bun.lock') {
|
|
96
|
+
packageManager = 'bun';
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
98
|
+
assert(packageManager);
|
|
99
|
+
return { packageManager, lockFile };
|
|
100
|
+
}
|