-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1614 from SUI-Components/typescript-support
[FEAT] typescript support
- Loading branch information
Showing
88 changed files
with
840 additions
and
531 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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
checks: | ||
name: Checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel Previous Redundant Builds | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Setup Chrome | ||
uses: browser-actions/setup-chrome@latest | ||
|
||
- name: Install | ||
run: | | ||
sudo apt-get install xvfb | ||
npm install --no-save --no-fund --no-audit --legacy-peer-deps | ||
npx -y ultra-runner --raw --recursive prepublishOnly | ||
- name: Lint | ||
run: npm run lint | ||
|
||
- name: Type Checking | ||
run: npm run types:check | ||
|
||
- name: Tests | ||
run: | | ||
npm run test:server:ci | ||
xvfb-run --auto-servernum npm run test:client:ci | ||
publish: | ||
name: Publish | ||
needs: checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Publish Packages | ||
if: github.ref == 'refs/heads/master' | ||
run: | | ||
npx -p ./packages/sui-mono sui-mono check | ||
npx -p ./packages/sui-ci sui-ci release | ||
env: | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
GITHUB_EMAIL: [email protected] | ||
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }} | ||
GITHUB_USER: sui-bot | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
publish-tagged-packages: | ||
name: Publish Tagged Packages to NPM | ||
needs: checks | ||
if: github.ref != 'refs/heads/master' && contains(github.event.pull_request.labels.*.name, 'feature') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Install | ||
run: npm install -D commander execa prettier | ||
|
||
- name: Get Files | ||
id: files | ||
uses: jitterbit/get-changed-files@v1 | ||
with: | ||
format: 'json' | ||
|
||
- name: Publish Packages | ||
run: npm run publish-tagged-packages -- --tag '${{ github.event.pull_request.head.ref }}' --files '${{ steps.files.outputs.added_modified }}' | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
node_modules/ | ||
lib/ | ||
coverage/ | ||
.DS_Store | ||
npm-debug.log | ||
.tern-port | ||
package-lock.json | ||
.idea/ | ||
.python-version | ||
.tern-port | ||
.vscode/ | ||
|
||
contract/logs/pact.log | ||
coverage/ | ||
jsconfig.json | ||
lib/ | ||
node_modules/ | ||
npm-debug.log | ||
package-lock.json | ||
|
||
!packages/sui-sass-loader/test/server/fixtures/**/node_modules | ||
packages/sui-codemod/COMMANDS | ||
sui-components-dashboard-9350df448fcd.json | ||
.idea/ | ||
.vscode/ | ||
packages/sui-studio/test/server/integration/empty-studio/components/fake/** | ||
packages/sui-studio/test/server/integration/empty-studio/components/fake/componentnvim | ||
packages/sui-studio/test/server/integration/empty-studio/demo/fake/** | ||
packages/sui-studio/test/server/integration/empty-studio/test/fake/** | ||
packages/sui-studio/test/server/integration/sample-studio/node_modules/ | ||
packages/sui-studio/test/server/integration/sample-studio/components/atom/button/node_modules/ | ||
packages/sui-studio/test/server/integration/sample-studio/node_modules/ | ||
packages/sui-studio/test/server/integration/sample-studio/public | ||
packages/sui-studio/test/server/integration/empty-studio/components/fake/componentnvim | ||
|
||
!packages/sui-sass-loader/test/server/fixtures/**/node_modules | ||
|
||
contract/logs/pact.log | ||
.npmrc | ||
sui-components-dashboard-9350df448fcd.json |
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 @@ | ||
legacy-peer-deps=true |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable no-console */ | ||
|
||
const crypto = require('crypto') | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const {writeFile} = require('@s-ui/helpers/file.js') | ||
|
||
const {INIT_CWD} = process.env | ||
const tsConfigTemplate = `\ | ||
{ | ||
"extends": "@s-ui/bundler/tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "./" | ||
}, | ||
"include": ["src", "domain", "components"] | ||
}` | ||
|
||
const md5 = str => crypto.createHash('md5').update(str).digest('hex') | ||
const TS_CONFIG_PATH = path.join(INIT_CWD, 'tsconfig.json') | ||
const PACKAGE_JSON_CONFIG_PATH = path.join(INIT_CWD, 'package.json') | ||
|
||
const config = require(PACKAGE_JSON_CONFIG_PATH)?.config?.['sui-bundler'] || {} | ||
|
||
const shouldGenerateTSConfig = () => { | ||
try { | ||
if (!config?.type || config?.type !== 'typescript') return false | ||
|
||
if (!fs.existsSync(TS_CONFIG_PATH)) return true | ||
|
||
const tsConfigLocal = fs.readFileSync(TS_CONFIG_PATH, {encoding: 'utf8'}) | ||
return md5(tsConfigLocal) !== md5(tsConfigTemplate) | ||
} catch (err) { | ||
return true | ||
} | ||
} | ||
|
||
async function main() { | ||
console.log('🔍 [sui-bundler postinstall] Checking if tsconfig.json is up to date...') | ||
if (!shouldGenerateTSConfig()) { | ||
console.log('✅ [sui-bundler postinstall] tsconfig.json is up to date') | ||
process.exit(0) | ||
} | ||
await writeFile(TS_CONFIG_PATH, tsConfigTemplate) | ||
console.log('❌ [sui-bundler postinstall] tsconfig.json was not up to date, so we updated it') | ||
} | ||
|
||
main() |
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
Oops, something went wrong.