Skip to content

Commit

Permalink
fix: Fix starter publish and scripts (#28260) (#28282)
Browse files Browse the repository at this point in the history
* Fix starter publish script

* Don't use yarn import because @arcanis says it's a bad idea
#28238 (comment)

(cherry picked from commit f6417dd)

Co-authored-by: Matt Kane <[email protected]>
  • Loading branch information
vladar and ascorbic authored Nov 25, 2020
1 parent 89bc8b7 commit bd3abae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 1 addition & 7 deletions packages/create-gatsby/src/init-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ const install = async (
}
}
if (getPackageManager() === `yarn` && checkForYarn()) {
if (await fs.pathExists(`package-lock.json`)) {
if (!(await fs.pathExists(`yarn.lock`))) {
await execa(`yarnpkg`, [`import`])
}
await fs.remove(`package-lock.json`)
}

await fs.remove(`package-lock.json`)
const args = packages.length ? [`add`, silent, ...packages] : [silent]
await execa(`yarnpkg`, args)
} else {
Expand Down
7 changes: 1 addition & 6 deletions packages/gatsby-cli/src/init-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ const install = async (rootPath: string): Promise<void> => {
}
}
if (getPackageManager() === `yarn` && checkForYarn()) {
if (await fs.pathExists(`package-lock.json`)) {
if (!(await fs.pathExists(`yarn.lock`))) {
await spawn(`yarnpkg import`)
}
await fs.remove(`package-lock.json`)
}
await fs.remove(`package-lock.json`)
await spawn(`yarnpkg`)
} else {
await fs.remove(`yarn.lock`)
Expand Down
5 changes: 4 additions & 1 deletion scripts/publish-starters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GLOB=$1
IS_CI="${CI:-false}"
BASE=$(pwd)
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
MINIMAL_STARTER=gatsby-starter-minimal

if [ "$IS_CI" = true ]; then
sudo apt-get update && sudo apt-get install jq
Expand All @@ -28,7 +29,9 @@ for folder in $GLOB; do

if [ "$IS_WORKSPACE" = null ]; then
rm -f yarn.lock
yarn import # generate a new yarn.lock file based on package-lock.json, gatsby new does this is new CLI versions but will ignore if file exists
if [ "$MINIMAL_STARTER" != "$NAME" ]; then # ignore minimal starter because we don't want any lock files for create-gatsby
yarn import # generate a new yarn.lock file based on package-lock.json, gatsby new does this is new CLI versions but will ignore if file exists
fi
fi

if [ -n "$(git status --porcelain)" ]; then
Expand Down

0 comments on commit bd3abae

Please sign in to comment.