Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
dc6b0f46
Commit
dc6b0f46
authored
8 years ago
by
Christopher Chedeau
Browse files
Options
Download
Email Patches
Plain Diff
initial version of export-scripts
I have no tested it :)
parent
2c80f43f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/export-scripts.js
+76
-0
scripts/export-scripts.js
with
76 additions
and
0 deletions
+76
-0
scripts/export-scripts.js
0 → 100644
+
76
-
0
View file @
dc6b0f46
var
fs
=
require
(
'
fs
'
);
if
(
!
(
process
.
argv
[
2
]
===
'
--i-know-what-im-doing
'
&&
process
.
argv
[
3
]
===
'
--there-is-no-going-back
'
))
{
console
.
log
(
'
This command will copy all the scripts and configurations
'
,
'
from the create-react-app command to your directory.
'
,
'
You will be able to tweak and extend them but be aware that
'
,
'
this is a one way operation, there is no going back
'
);
console
.
log
(
'
If you want to run this, please type the following command
'
);
console
.
log
(
'
npm run export-scripts --i-know-what-im-doing --there-is-no-going-back
'
);
process
.
exit
(
1
);
}
console
.
log
(
'
Extracting scripts...
'
);
var
hostPath
=
__dirname
;
var
selfPath
=
hostPath
+
'
/node_modules/create-react-app-scripts
'
;
var
files
=
[
'
scripts
'
,
'
.webpack.config.dev.js
'
,
'
.webpack.config.prod.js
'
,
'
.babelrc
'
,
'
.eslintrc
'
,
];
// Ensure that the host folder is clean and we won't override any files
files
.
forEach
(
function
(
file
)
{
if
(
fs
.
existsSync
(
hostPath
+
'
/
'
+
file
))
{
console
.
error
(
'
`
'
+
file
+
'
` already exists on your app folder, we cannot
'
+
'
continue as you would lose all the changes.
'
,
'
Please delete it (maybe make a copy for backup) and run this
'
+
'
command again.
'
);
process
.
exit
(
1
);
}
});
// Move the files over
files
.
forEach
(
function
(
file
)
{
fs
.
renameSync
(
selfPath
+
'
/
'
+
file
,
hostPath
+
'
/
'
+
file
);
});
var
hostPackage
=
require
(
hostPath
+
'
/package.json
'
);
var
selfPackage
=
require
(
selfPath
+
'
/package.json
'
);
// Copy over dependencies
hostPackage
.
dependencies
=
hostPackage
.
dependencies
||
{};
for
(
var
key
in
selfPackage
.
dependencies
)
{
hostPackage
.
devDependencies
[
key
]
=
selfPackage
.
dependencies
[
key
];
}
delete
hostPackage
.
dependencies
[
'
create-react-app-scripts
'
];
// Update the script rules
[
'
start
'
,
'
build
'
].
forEach
(
function
(
command
)
{
hostPackage
.
scripts
[
command
]
=
'
node scripts/
'
+
command
+
'
.js local
'
;
});
delete
hostPackage
[
'
export-scripts
'
];
fs
.
writeFileSync
(
hostPath
+
'
/package.json
'
,
JSON
.
stringify
(
hostPackage
,
null
,
2
));
// TODO: run npm install in hostPath
// Move the src folder
console
.
log
(
'
Done!
'
);
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment