-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing sandbox generation script for main
- Loading branch information
Showing
13 changed files
with
128 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,10 @@ jobs: | |
git config --global user.name "Storybook Bot" | ||
git config --global user.email "[email protected]" | ||
- name: Install dependencies | ||
run: node ./scripts/check-dependencies.js | ||
run: | | ||
cd ./scripts | ||
node --experimental-modules ./check-dependencies.js | ||
cd .. | ||
- name: Compile Storybook libraries | ||
run: yarn task --task compile --start-from=auto --no-link | ||
- name: Publishing to local registry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,10 @@ jobs: | |
git config --global user.name "Storybook Bot" | ||
git config --global user.email "[email protected]" | ||
- name: Install dependencies | ||
run: node ./scripts/check-dependencies.js | ||
run: | | ||
cd ./scripts | ||
node --experimental-modules ./check-dependencies.js | ||
cd .. | ||
- name: Compile Storybook libraries | ||
run: yarn task --task compile --start-from=auto --no-link | ||
- name: Publishing to local registry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,72 @@ | ||
#!/usr/bin/env node | ||
const { checkDependencies } = require('./utils/cli-utils'); | ||
/** | ||
* This file needs to be run before any other script to ensure dependencies are installed | ||
* Therefore, we cannot transform this file to Typescript, because it would require esbuild to be installed | ||
*/ | ||
import { spawn } from 'child_process'; | ||
import { join } from 'path'; | ||
import { existsSync } from 'fs'; | ||
import * as url from 'url'; | ||
|
||
const logger = console; | ||
|
||
const filename = url.fileURLToPath(import.meta.url); | ||
const dirname = url.fileURLToPath(new URL('.', import.meta.url)); | ||
|
||
const checkDependencies = async () => { | ||
const scriptsPath = join(dirname); | ||
const codePath = join(dirname, '..', 'code'); | ||
|
||
const tasks = []; | ||
|
||
if (!existsSync(join(scriptsPath, 'node_modules'))) { | ||
tasks.push( | ||
spawn('yarn', ['install'], { | ||
cwd: scriptsPath, | ||
shell: true, | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
}) | ||
); | ||
} | ||
if (!existsSync(join(codePath, 'node_modules'))) { | ||
tasks.push( | ||
spawn('yarn', ['install'], { | ||
cwd: codePath, | ||
shell: true, | ||
stdio: ['inherit', 'inherit', 'inherit'], | ||
}) | ||
); | ||
} | ||
|
||
if (tasks.length > 0) { | ||
logger.log('installing dependencies'); | ||
|
||
await Promise.all( | ||
tasks.map( | ||
(t) => | ||
new Promise((res, rej) => { | ||
t.on('exit', (code) => { | ||
if (code !== 0) { | ||
rej(); | ||
} else { | ||
res(); | ||
} | ||
}); | ||
}) | ||
) | ||
).catch(() => { | ||
tasks.forEach((t) => t.kill()); | ||
throw new Error('Failed to install dependencies'); | ||
}); | ||
|
||
// give the filesystem some time | ||
await new Promise((res) => { | ||
setTimeout(res, 1000); | ||
}); | ||
} | ||
}; | ||
|
||
checkDependencies().catch((e) => { | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters