Skip to content

Commit 2a302d6

Browse files
author
Ahmad Awais
committed
📦 NEW: Eject Script
1 parent 4beb6a8 commit 2a302d6

7 files changed

Lines changed: 663 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ First of all, I'd like to welcome you for thinking about contributing to this pr
2828
- Run `npm start` or `yarn start`
2929
- This will compile your code in `dist` and you're good to go.
3030
- Run `yarn updated` to check which npm packages were updated
31-
- Finally publish with 'yarn publishNPM' since yarn has some issues with publishing with lerna not sure why.
31+
- Finally publish with 'yarn publishNPM' since yarn has some issues with publishing with lerna not sure why.
32+
33+
34+
35+
### Other Stuff
36+
37+
- Use `// @remove-file-on-eject` to do just that.
38+
- Use `// @remove-on-eject-begin` to do just that.
39+
- Use `// @remove-on-eject-end` to do just that.

packages/cgb-scripts/config/paths.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,26 @@ const fs = require( 'fs' );
1111
const pluginDir = fs.realpathSync( process.cwd() );
1212
const resolveApp = relativePath => path.resolve( pluginDir, relativePath );
1313

14+
// Config after eject: we're in ./config/
1415
module.exports = {
1516
dotenv: resolveApp( '.env' ),
1617
pluginBlocksJs: resolveApp( 'src/blocks.js' ),
18+
yarnLockFile: resolveApp( 'yarn.lock' ),
1719
pluginDist: resolveApp( '.' ), // We are in ./dist folder already so the path '.' resolves to ./dist/.
1820
};
21+
22+
// @remove-on-eject-begin
23+
const resolveOwn = relativePath => path.resolve( __dirname, '..', relativePath );
24+
25+
// config before eject: we're in ./node_modules/react-scripts/config/
26+
module.exports = {
27+
dotenv: resolveApp( '.env' ),
28+
pluginBlocksJs: resolveApp( 'src/blocks.js' ),
29+
pluginDist: resolveApp( '.' ), // We are in ./dist folder already so the path '.' resolves to ./dist/.
30+
yarnLockFile: resolveApp( 'yarn.lock' ),
31+
appPath: resolveApp( '.' ),
32+
// These properties only exist before ejecting:
33+
ownPath: resolveOwn( '.' ),
34+
};
35+
36+
console.log( resolveApp( '.' ) );

packages/cgb-scripts/eject/paths.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ const fs = require( 'fs' );
1111
const pluginDir = fs.realpathSync( process.cwd() );
1212
const resolveApp = relativePath => path.resolve( pluginDir, relativePath );
1313

14+
// Config after eject: we're in ./config/
1415
module.exports = {
1516
dotenv: resolveApp( '.env' ),
1617
pluginBlocksJs: resolveApp( 'src/blocks.js' ),
1718
pluginDist: resolveApp( '.' ), // We are in ./dist folder already so the path '.' resolves to ./dist/.
1819
};
20+
21+
// @remove-on-eject-begin
22+
const resolveOwn = relativePath => path.resolve( __dirname, '..', relativePath );
23+
24+
// config before eject: we're in ./node_modules/react-scripts/config/
25+
module.exports = {
26+
dotenv: resolveApp( '.env' ),
27+
pluginBlocksJs: resolveApp( 'src/blocks.js' ),
28+
pluginDist: resolveApp( '.' ), // We are in ./dist folder already so the path '.' resolves to ./dist/.
29+
appPath: resolveApp( '.' ),
30+
// These properties only exist before ejecting:
31+
ownPath: resolveOwn( '.' ),
32+
};
33+
34+
console.log( ownPath );

0 commit comments

Comments
 (0)