Skip to content

Commit

Permalink
feat(scaffolding): enforce location within projectRoot & run yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsalker committed Jul 20, 2020
1 parent a3c3f40 commit b34ec8c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/cli-plugin-scaffold-node-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = [
type: "cli-plugin-scaffold-template",
scaffold: {
name: "Node Package",
questions: () => {
questions: ({ context }) => {
return [
{
name: "location",
Expand All @@ -21,6 +21,13 @@ module.exports = [
return "Please enter a package location";
}

const fullLocation = path.resolve(location);
const projectLocation = context.paths.projectRoot;
if (path.relative(fullLocation, projectLocation).match(/[^.\\]/)) {
return "The target location must be within the Webiny project's root";
}
return "fuck";

if (fs.existsSync(path.resolve(location))) {
return "The target location already exists";
}
Expand Down Expand Up @@ -99,6 +106,9 @@ module.exports = [
const tsconfigBuild = require(tsconfigBuildPath);
tsconfigBuild.extends = baseTsConfigBuildPath;
fs.writeFileSync(tsconfigBuildPath, JSON.stringify(tsconfigBuild, null, 2));

// Run Yarn to link the new package to the monorepo
await execa("yarn");
}
}
}
Expand Down

0 comments on commit b34ec8c

Please sign in to comment.