Skip to content

Commit cfba6e6

Browse files
author
Ahmad Awais ⚡️
authored
📦 NEW: Eject Script PR #1
📦 NEW: Eject Script Merge pull request #1 from ahmadawais/develop-eject
2 parents ce4e3ea + f0f1ff2 commit cfba6e6

12 files changed

Lines changed: 721 additions & 7 deletions

File tree

CONTRIBUTING.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,18 @@ 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+
- Check caveats for publishing.
33+
34+
### 🤔 Caveats
35+
36+
- Some issue with yarn not being able to publish via lerna
37+
- Use yarn with everything else but lerna
38+
- To publish always run via `npm` this command `npm run lerna`
39+
40+
41+
### 🐵 Other Stuff
42+
43+
- Use `// @remove-file-on-eject` to do just that.
44+
- Use `// @remove-on-eject-begin` to do just that.
45+
- Use `// @remove-on-eject-end` to do just that.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"beforepublish": "lerna bootstrap",
3636
"publish":
3737
"bash tasks/publish.sh && echo 'Now update dependency packages.'",
38-
"publishNPM": "bash tasks/publish.sh --npm-client=npm"
38+
"publishNPM": "bash tasks/publish.sh --npm-client=npm",
39+
"lerna":
40+
"lerna updated && lerna bootstrap && lerna publish --independent --npm-client=npm"
3941
}
4042
}

packages/cgb-scripts/config/paths.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,25 @@ 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+
// @remove-on-eject-end

packages/cgb-scripts/config/webpack.config.dev.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ module.exports = {
9393
use: {
9494
loader: 'babel-loader',
9595
options: {
96+
// @remove-on-eject-begin
9697
babelrc: false,
9798
presets: [ require.resolve( 'babel-preset-cgb' ) ],
99+
// @remove-on-eject-end
98100
// This is a feature of `babel-loader` for webpack (not Babel itself).
99101
// It enables caching results in ./node_modules/.cache/babel-loader/
100102
// directory for faster rebuilds.

packages/cgb-scripts/config/webpack.config.prod.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ module.exports = {
9393
use: {
9494
loader: 'babel-loader',
9595
options: {
96+
// @remove-on-eject-begin
9697
babelrc: false,
9798
presets: [ require.resolve( 'babel-preset-cgb' ) ],
99+
// @remove-on-eject-end
98100
// This is a feature of `babel-loader` for webpack (not Babel itself).
99101
// It enables caching results in ./node_modules/.cache/babel-loader/
100102
// directory for faster rebuilds.

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)