-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: smart build and smart dev (#270)
* chore: add dev or build smart * fix: lint issues * fix: lint
- Loading branch information
1 parent
239d6be
commit a1a02d9
Showing
8 changed files
with
149 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
componentName=$1 | ||
turboDependenciesFilter=[] | ||
|
||
if [ ! -d "packages/components/$componentName" ] | ||
then | ||
echo "Component does not exist" | ||
exit 1 | ||
fi | ||
|
||
dependencies=$(cat packages/components/$componentName/package.json | jq -r '.dependencies | keys[] | select(. | startswith("@oku-ui"))') | ||
|
||
filter_arguments="" | ||
for dependency in $dependencies | ||
do | ||
if [[ "$dependency" == @oku-ui* ]] | ||
then | ||
filter_arguments+="--filter=$dependency " | ||
fi | ||
done | ||
|
||
turbo build $filter_arguments |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { readFileSync, readdirSync } from 'node:fs' | ||
import { resolve } from 'node:path' | ||
import process from 'node:process' | ||
import { execaCommandSync } from 'execa' | ||
|
||
const isCore = process.argv[2].endsWith('core') | ||
let where = 'packages' | ||
|
||
if (isCore) | ||
where = where.concat('/core') | ||
else | ||
where = where.concat('/components') | ||
|
||
const componentName = isCore ? process.argv[3] : process.argv[2] | ||
|
||
let turboDependenciesFilter: string = '' | ||
|
||
async function main() { | ||
const componentFile = resolve(process.cwd(), where, componentName) | ||
|
||
if (readdirSync(componentFile).length === 0) { | ||
console.error(`${componentName} does not exist`) | ||
process.exit(1) | ||
} | ||
|
||
const dependencies = readFileSync(resolve(componentFile, 'package.json'), 'utf-8') | ||
const packageName = JSON.parse(dependencies).name | ||
const filteredDependencies = Object.entries(JSON.parse(dependencies).dependencies) | ||
.filter(([name]) => name.startsWith('@oku-ui')) | ||
.filter(([name]) => !turboDependenciesFilter.includes(name)) | ||
.map(([name]) => name) | ||
.map(name => `--filter=${name}`) | ||
.join(' ') | ||
|
||
turboDependenciesFilter = filteredDependencies.concat(` --filter=${packageName}`) | ||
} | ||
|
||
await main() | ||
execaCommandSync(`turbo build ${turboDependenciesFilter}`, { stdio: 'inherit' }) |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
componentName=$1 | ||
turboDependenciesFilter=[] | ||
|
||
if [ ! -d "packages/components/$componentName" ] | ||
then | ||
echo "Component does not exist" | ||
exit 1 | ||
fi | ||
|
||
dependencies=$(cat packages/components/$componentName/package.json | jq -r '.dependencies | keys[] | select(. | startswith("@oku-ui"))') | ||
|
||
filter_arguments="" | ||
for dependency in $dependencies | ||
do | ||
if [[ "$dependency" == @oku-ui* ]] | ||
then | ||
filter_arguments+="--filter=$dependency " | ||
fi | ||
done | ||
|
||
turbo dev $filter_arguments |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { readFileSync, readdirSync } from 'node:fs' | ||
import { resolve } from 'node:path' | ||
import process from 'node:process' | ||
import { execaCommandSync } from 'execa' | ||
|
||
const isCore = process.argv[2].endsWith('core') | ||
let where = 'packages' | ||
|
||
if (isCore) | ||
where = where.concat('/core') | ||
else | ||
where = where.concat('/components') | ||
|
||
const componentName = isCore ? process.argv[3] : process.argv[2] | ||
|
||
let turboDependenciesFilter: string = '' | ||
|
||
async function main() { | ||
const componentFile = resolve(process.cwd(), where, componentName) | ||
|
||
if (readdirSync(componentFile).length === 0) { | ||
console.error(`${componentName} does not exist`) | ||
process.exit(1) | ||
} | ||
|
||
const dependencies = readFileSync(resolve(componentFile, 'package.json'), 'utf-8') | ||
const packageName = JSON.parse(dependencies).name | ||
const filteredDependencies = Object.entries(JSON.parse(dependencies).dependencies) | ||
.filter(([name]) => name.startsWith('@oku-ui')) | ||
.filter(([name]) => !turboDependenciesFilter.includes(name)) | ||
.map(([name]) => name) | ||
.map(name => `--filter=${name}`) | ||
.join(' ') | ||
|
||
turboDependenciesFilter = filteredDependencies.concat(` --filter=${packageName}`) | ||
} | ||
|
||
await main() | ||
execaCommandSync(`turbo dev ${turboDependenciesFilter}`, { stdio: 'inherit' }) |
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