Skip to content

Commit

Permalink
feat: normalize dependencies & devDependencies in bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
swashata committed Oct 22, 2018
1 parent 297b54d commit be44080
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
27 changes: 19 additions & 8 deletions packages/scripts/src/bin/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,14 @@ export async function bootstrap(
spinner.start(
`installing dependencies${watchEllipsis} may take a while`
);
await execa(command, [add, ...done.deps.dependencies]);
spinner.succeed('done installing dependencies\n');

try {
await execa(command, [add, ...done.deps.dependencies]);
spinner.succeed('done installing dependencies\n');
} catch (e) {
spinner.fail('could not install all dependencies');
console.log(pe.render(e));
}
}
if (done.deps && done.deps.devDependencies.length) {
console.log(
Expand All @@ -90,13 +96,18 @@ export async function bootstrap(
spinner.start(
`installing dev dependencies${watchEllipsis} may take a while`
);
await execa(command, [
add,
...done.deps.devDependencies,
devParam,
]);

spinner.succeed('done installing dependencies\n');
try {
await execa(command, [
add,
...done.deps.devDependencies,
devParam,
]);
spinner.succeed('done installing devDependencies\n');
} catch (e) {
spinner.fail('could not install all devDependencies');
console.log(pe.render(e));
}
}
} catch (e) {
console.log(
Expand Down
19 changes: 13 additions & 6 deletions packages/scripts/src/scripts/Bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ interface Pkg {
dependencies?: {
[x: string]: string;
};
devDependencies?: {
[x: string]: string;
};
}

interface ProjectConfigContext {
Expand Down Expand Up @@ -309,15 +312,19 @@ module.exports = {
});

// Add dependencies of @wpackio/entrypoint and @wpackio/scripts if needed
const dependencies: string[] = [];
const devDependencies: string[] = ['@wpackio/scripts'];
const dependencies: string[] = ['@wpackio/entrypoint'];
const devDependencies: string[] = [];

// If @wpackio/scripts is not already present in devDependencies
// Then push it. We do this check, because @wpackio/cli might already
// have installed it during scaffolding.
if (
!packageFileData.dependencies ||
!packageFileData.dependencies['@wpackio/entrypoint']
!packageFileData.devDependencies ||
!packageFileData.devDependencies['@wpackio/scripts']
) {
dependencies.push('@wpackio/entrypoint');
devDependencies.push('@wpackio/scripts');
}
// If has Sass
// If has Sass, then push node-sass
if (projectContext.hasSass === 'true') {
devDependencies.push('node-sass');
}
Expand Down
26 changes: 25 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7071,6 +7071,30 @@ node-sass@^4.9.3:
stdout-stream "^1.4.0"
"true-case-path" "^1.0.2"

node-sass@^4.9.4:
version "4.9.4"
resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.9.4.tgz#349bd7f1c89422ffe7e1e4b60f2055a69fbc5512"
dependencies:
async-foreach "^0.1.3"
chalk "^1.1.1"
cross-spawn "^3.0.0"
gaze "^1.0.0"
get-stdin "^4.0.1"
glob "^7.0.3"
in-publish "^2.0.0"
lodash.assign "^4.2.0"
lodash.clonedeep "^4.3.2"
lodash.mergewith "^4.6.0"
meow "^3.7.0"
mkdirp "^0.5.1"
nan "^2.10.0"
node-gyp "^3.8.0"
npmlog "^4.0.0"
request "^2.88.0"
sass-graph "^2.2.4"
stdout-stream "^1.4.0"
"true-case-path" "^1.0.2"

"nopt@2 || 3":
version "3.0.6"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
Expand Down Expand Up @@ -8766,7 +8790,7 @@ [email protected]:
tunnel-agent "^0.6.0"
uuid "^3.1.0"

request@^2.87.0:
request@^2.87.0, request@^2.88.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
dependencies:
Expand Down

0 comments on commit be44080

Please sign in to comment.