From 3e850acad7b1e761cf445bf84a936615f0329ae5 Mon Sep 17 00:00:00 2001 From: Josef Bredreck Date: Sun, 18 Oct 2020 19:24:44 +0200 Subject: [PATCH 1/2] Fix create script --- packages/cli/bin/cli-actions/init.js | 1 + packages/cli/bin/utils.js | 6 +++++- packages/cli/package.json | 2 +- yarn.lock | 24 +++++++++++++----------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/cli/bin/cli-actions/init.js b/packages/cli/bin/cli-actions/init.js index afc715a99..f7bbd2f34 100644 --- a/packages/cli/bin/cli-actions/init.js +++ b/packages/cli/bin/cli-actions/init.js @@ -46,6 +46,7 @@ const init = options => ); // 1 yield scaffold(projectDir, sourceDir, publicDir, exportDir); // 2 + process.env.projectDir = path.join(process.cwd(), projectDir); if (edition) { spinner.text = `⊙ patternlab → Installing edition: ${edition}`; diff --git a/packages/cli/bin/utils.js b/packages/cli/bin/utils.js index 23ae9544a..62a081683 100644 --- a/packages/cli/bin/utils.js +++ b/packages/cli/bin/utils.js @@ -135,7 +135,11 @@ const fetchPackage = packageName => const installCmd = useYarn ? 'add' : 'install'; try { if (packageName) { - const cmd = yield spawn(pm, [installCmd, packageName]); + const opts = {}; + if (process.env.projectDir) { + opts.cwd = process.env.projectDir; + } + const cmd = yield spawn(pm, [installCmd, packageName], opts); error(cmd.stderr); } } catch (err) { diff --git a/packages/cli/package.json b/packages/cli/package.json index 27a8e0c7e..a1d5f031a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -16,7 +16,7 @@ "chalk": "2.4.1", "commander": "2.15.1", "deepmerge": "^2.1.1", - "execa": "0.10.0", + "execa": "4.0.3", "fs-extra": "6.0.1", "glob": "7.1.2", "has-yarn": "1.0.0", diff --git a/yarn.lock b/yarn.lock index 816bf0e86..07ac50602 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7907,18 +7907,20 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: md5.js "^1.3.4" safe-buffer "^5.1.1" -execa@0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/execa/-/execa-0.10.0.tgz#ff456a8f53f90f8eccc71a96d11bdfc7f082cb50" - integrity sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw== +execa@4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.3.tgz#0a34dabbad6d66100bd6f2c576c8669403f317f2" + integrity sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A== dependencies: - cross-spawn "^6.0.0" - get-stream "^3.0.0" - is-stream "^1.1.0" - npm-run-path "^2.0.0" - p-finally "^1.0.0" - signal-exit "^3.0.0" - strip-eof "^1.0.0" + cross-spawn "^7.0.0" + get-stream "^5.0.0" + human-signals "^1.1.1" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.0" + onetime "^5.1.0" + signal-exit "^3.0.2" + strip-final-newline "^2.0.0" execa@^0.7.0: version "0.7.0" From 05e07cc3c785387e7157955bb5f0662be78c8cdc Mon Sep 17 00:00:00 2001 From: Josef Bredreck Date: Sun, 18 Oct 2020 19:51:38 +0200 Subject: [PATCH 2/2] Update path resolving of source folder --- packages/cli/bin/install-starterkit.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cli/bin/install-starterkit.js b/packages/cli/bin/install-starterkit.js index 602f7236d..5de245b1e 100644 --- a/packages/cli/bin/install-starterkit.js +++ b/packages/cli/bin/install-starterkit.js @@ -17,7 +17,10 @@ const installStarterkit = (starterkit, config) => const sourceDir = config.paths.source.root; const name = starterkit.value || starterkit; yield checkAndInstallPackage(name); - yield copyAsync(resolveDirInPackage(name, 'dist'), path.resolve(sourceDir)); + yield copyAsync( + resolveDirInPackage(name, 'dist'), + path.resolve(process.env.projectDir || '', sourceDir) + ); let kitConfig; const kitConfigPath = path.join( resolvePackageFolder(name),