Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
2987cc69
Commit
2987cc69
authored
8 years ago
by
Dan Abramov
Committed by
Christopher Chedeau
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Get graduate working
parent
4b4a8a15
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
package.json
+2
-2
package.json
scripts/build.js
+4
-1
scripts/build.js
scripts/graduate.js
+40
-9
scripts/graduate.js
scripts/init.js
+9
-5
scripts/init.js
webpack.config.dev.js
+3
-1
webpack.config.dev.js
webpack.config.prod.js
+3
-1
webpack.config.prod.js
with
61 additions
and
19 deletions
+61
-19
package.json
+
2
-
2
View file @
2987cc69
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
"name"
:
"create-react-app-scripts"
,
"name"
:
"create-react-app-scripts"
,
"version"
:
"0.0.1"
,
"version"
:
"0.0.1"
,
"scripts"
:
{
"scripts"
:
{
"start"
:
"node scripts/start.js
local
"
,
"start"
:
"node scripts/start.js"
,
"build"
:
"node scripts/build.js
local
"
,
"build"
:
"node scripts/build.js"
,
"create-react-app"
:
"node global-cli/index.js --scripts-version
\"
$PWD/`npm pack`
\"
"
"create-react-app"
:
"node global-cli/index.js --scripts-version
\"
$PWD/`npm pack`
\"
"
},
},
"bin"
:
{
"bin"
:
{
...
...
This diff is collapsed.
Click to expand it.
scripts/build.js
+
4
-
1
View file @
2987cc69
...
@@ -9,11 +9,14 @@
...
@@ -9,11 +9,14 @@
process
.
env
.
NODE_ENV
=
'
production
'
;
process
.
env
.
NODE_ENV
=
'
production
'
;
var
path
=
require
(
'
path
'
);
var
spawnSync
=
require
(
'
child_process
'
).
spawnSync
;
var
spawnSync
=
require
(
'
child_process
'
).
spawnSync
;
var
webpack
=
require
(
'
webpack
'
);
var
webpack
=
require
(
'
webpack
'
);
var
config
=
require
(
'
../webpack.config.prod
'
);
var
config
=
require
(
'
../webpack.config.prod
'
);
var
relative
=
process
.
argv
[
2
]
===
'
local
'
?
'
.
'
:
'
../..
'
;
var
isInNodeModules
=
'
node_modules
'
===
path
.
basename
(
path
.
resolve
(
path
.
join
(
__dirname
,
'
..
'
,
'
..
'
)));
var
relative
=
isInNodeModules
?
'
../..
'
:
'
.
'
;
spawnSync
(
'
rm
'
,
[
'
-rf
'
,
relative
+
'
/build
'
]);
spawnSync
(
'
rm
'
,
[
'
-rf
'
,
relative
+
'
/build
'
]);
webpack
(
config
).
run
(
function
(
err
,
stats
)
{
webpack
(
config
).
run
(
function
(
err
,
stats
)
{
...
...
This diff is collapsed.
Click to expand it.
scripts/graduate.js
+
40
-
9
View file @
2987cc69
...
@@ -8,26 +8,28 @@
...
@@ -8,26 +8,28 @@
*/
*/
var
fs
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
console
.
log
(
'
Extracting scripts...
'
);
console
.
log
(
'
Extracting scripts...
'
);
console
.
log
();
var
host
Path
=
__dirname
;
var
self
Path
=
path
.
join
(
__dirname
,
'
..
'
)
;
var
self
Path
=
hostPath
+
'
/node_modules/create-react-app-scripts
'
;
var
host
Path
=
path
.
join
(
selfPath
,
'
..
'
,
'
..
'
)
;
var
files
=
[
var
files
=
[
'
scripts
'
,
'
scripts
'
,
'
.
webpack.config.dev.js
'
,
'
webpack.config.dev.js
'
,
'
.
webpack.config.prod.js
'
,
'
webpack.config.prod.js
'
,
'
.babelrc
'
,
'
.babelrc
'
,
'
.eslintrc
'
,
'
.eslintrc
'
,
];
];
// Ensure that the host folder is clean and we won't override any files
// Ensure that the host folder is clean and we won't override any files
files
.
forEach
(
function
(
file
)
{
files
.
forEach
(
function
(
file
)
{
if
(
fs
.
existsSync
(
hostPath
+
'
/
'
+
file
))
{
if
(
fs
.
existsSync
(
path
.
join
(
hostPath
,
file
))
)
{
console
.
error
(
console
.
error
(
'
`
'
+
file
+
'
` already exists
o
n your app folder
, w
e cannot
'
+
'
`
'
+
file
+
'
` already exists
i
n your app folder
. W
e cannot
'
+
'
continue as you would lose all the changes in that file
.
'
,
'
continue as you would lose all the changes in that file
or directory.
'
+
'
Please delete it (maybe make a copy for backup) and run this
'
+
'
Please delete it (maybe make a copy for backup) and run this
'
+
'
command again.
'
'
command again.
'
);
);
...
@@ -37,9 +39,38 @@ files.forEach(function(file) {
...
@@ -37,9 +39,38 @@ files.forEach(function(file) {
// Move the files over
// Move the files over
files
.
forEach
(
function
(
file
)
{
files
.
forEach
(
function
(
file
)
{
fs
.
renameSync
(
selfPath
+
'
/
'
+
file
,
hostPath
+
'
/
'
+
file
);
console
.
log
(
'
Moving
'
+
file
+
'
to
'
+
hostPath
);
fs
.
renameSync
(
path
.
join
(
selfPath
,
file
),
path
.
join
(
hostPath
,
file
));
});
});
var
hostPackage
=
require
(
hostPath
+
'
/package.json
'
);
// These are unnecessary after graduation
fs
.
unlinkSync
(
path
.
join
(
hostPath
,
'
scripts
'
,
'
init.js
'
));
fs
.
unlinkSync
(
path
.
join
(
hostPath
,
'
scripts
'
,
'
graduate.js
'
));
console
.
log
();
var
selfPackage
=
require
(
path
.
join
(
selfPath
,
'
package.json
'
));
var
hostPackage
=
require
(
path
.
join
(
hostPath
,
'
package.json
'
));
console
.
log
(
'
Removing dependency: create-react-app-scripts
'
);
delete
hostPackage
.
devDependencies
[
'
create-react-app-scripts
'
];
Object
.
keys
(
selfPackage
.
dependencies
).
forEach
(
function
(
key
)
{
console
.
log
(
'
Adding dependency:
'
+
key
);
hostPackage
.
devDependencies
[
key
]
=
selfPackage
.
dependencies
[
key
];
});
console
.
log
(
'
Updating scripts
'
);
Object
.
keys
(
hostPackage
.
scripts
).
forEach
(
function
(
key
)
{
hostPackage
.
scripts
[
key
]
=
'
node ./scripts/
'
+
key
+
'
.js
'
});
delete
hostPackage
.
scripts
[
'
graduate
'
];
console
.
log
(
'
Writing package.json...
'
);
fs
.
writeFileSync
(
path
.
join
(
hostPath
,
'
package.json
'
),
JSON
.
stringify
(
hostPackage
,
null
,
2
)
);
console
.
log
();
console
.
log
(
'
Done!
'
);
console
.
log
(
'
Done!
'
);
This diff is collapsed.
Click to expand it.
scripts/init.js
+
9
-
5
View file @
2987cc69
...
@@ -8,12 +8,13 @@
...
@@ -8,12 +8,13 @@
*/
*/
var
fs
=
require
(
'
fs
'
);
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
module
.
exports
=
function
(
hostPath
,
appName
)
{
module
.
exports
=
function
(
hostPath
,
appName
)
{
var
selfPath
=
hostPath
+
'
/
node_modules
/
create-react-app-scripts
'
;
var
selfPath
=
path
.
join
(
hostPath
,
'
node_modules
'
,
'
create-react-app-scripts
'
)
;
var
hostPackage
=
require
(
hostPath
+
'
/
package.json
'
);
var
hostPackage
=
require
(
path
.
join
(
hostPath
,
'
package.json
'
)
)
;
var
selfPackage
=
require
(
selfPath
+
'
/
package.json
'
);
var
selfPackage
=
require
(
path
.
join
(
selfPath
,
'
package.json
'
)
)
;
// Copy over devDependencies
// Copy over devDependencies
hostPackage
.
dependencies
=
hostPackage
.
dependencies
||
{};
hostPackage
.
dependencies
=
hostPackage
.
dependencies
||
{};
...
@@ -28,12 +29,15 @@ module.exports = function(hostPath, appName) {
...
@@ -28,12 +29,15 @@ module.exports = function(hostPath, appName) {
command
+
'
-react-app
'
;
command
+
'
-react-app
'
;
});
});
fs
.
writeFileSync
(
hostPath
+
'
/package.json
'
,
JSON
.
stringify
(
hostPackage
,
null
,
2
));
fs
.
writeFileSync
(
path
.
join
(
hostPath
,
'
package.json
'
),
JSON
.
stringify
(
hostPackage
,
null
,
2
)
);
// TODO: run npm install in hostPath, (not needed for npm 3 if we accept some hackery)
// TODO: run npm install in hostPath, (not needed for npm 3 if we accept some hackery)
// Move the src folder
// Move the src folder
fs
.
renameSync
(
selfPath
+
'
/
src
'
,
hostPath
+
'
/
src
'
);
fs
.
renameSync
(
path
.
join
(
selfPath
,
'
src
'
)
,
path
.
join
(
hostPath
,
'
src
'
)
)
;
console
.
log
(
'
Success! Created
'
+
appName
+
'
at
'
+
hostPath
+
'
.
'
);
console
.
log
(
'
Success! Created
'
+
appName
+
'
at
'
+
hostPath
+
'
.
'
);
console
.
log
();
console
.
log
();
...
...
This diff is collapsed.
Click to expand it.
webpack.config.dev.js
+
3
-
1
View file @
2987cc69
...
@@ -12,7 +12,9 @@ var autoprefixer = require('autoprefixer');
...
@@ -12,7 +12,9 @@ var autoprefixer = require('autoprefixer');
var
webpack
=
require
(
'
webpack
'
);
var
webpack
=
require
(
'
webpack
'
);
var
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
);
var
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
);
var
relative
=
process
.
argv
[
2
]
===
'
local
'
?
'
.
'
:
'
../..
'
;
var
isInNodeModules
=
'
node_modules
'
===
path
.
basename
(
path
.
resolve
(
path
.
join
(
__dirname
,
'
..
'
)));
var
relative
=
isInNodeModules
?
'
../..
'
:
'
.
'
;
module
.
exports
=
{
module
.
exports
=
{
devtool
:
'
eval
'
,
devtool
:
'
eval
'
,
...
...
This diff is collapsed.
Click to expand it.
webpack.config.prod.js
+
3
-
1
View file @
2987cc69
...
@@ -12,7 +12,9 @@ var autoprefixer = require('autoprefixer');
...
@@ -12,7 +12,9 @@ var autoprefixer = require('autoprefixer');
var
webpack
=
require
(
'
webpack
'
);
var
webpack
=
require
(
'
webpack
'
);
var
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
);
var
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
);
var
relative
=
process
.
argv
[
2
]
===
'
local
'
?
'
.
'
:
'
../..
'
;
var
isInNodeModules
=
'
node_modules
'
===
path
.
basename
(
path
.
resolve
(
path
.
join
(
__dirname
,
'
..
'
)));
var
relative
=
isInNodeModules
?
'
../..
'
:
'
.
'
;
module
.
exports
=
{
module
.
exports
=
{
devtool
:
'
source-map
'
,
devtool
:
'
source-map
'
,
...
...
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
Menu
Explore
Projects
Groups
Snippets