-
Notifications
You must be signed in to change notification settings - Fork 40
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 #36 from statelyai/matt/added-typegen-to-authentic…
…ation-pr Added typegen to authentication PR
- Loading branch information
Showing
23 changed files
with
950 additions
and
103 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,34 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
cache: "yarn" | ||
|
||
- run: yarn | ||
- run: npx vsce package | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: xstate-vscode | ||
path: "*.vsix" | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: success() && startsWith( github.ref, 'refs/tags/') | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
- run: npx vsce publish --packagePath $(find . -iname *.vsix) | ||
env: | ||
VSCE_PAT: ${{ secrets.VSCE_PAT }} |
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,3 @@ | ||
export const BASE_URL = "https://stately.ai"; | ||
export const TOKEN_KEY = `stately-editor-key#${BASE_URL}`; | ||
export const EXTENSION_ID = "mattpocock.xstate-vscode"; |
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,33 @@ | ||
import { IntrospectMachineResult, SubState } from "xstate-vscode-shared"; | ||
|
||
export const getStateMatchesObjectSyntax = ( | ||
introspectionResult: IntrospectMachineResult, | ||
): string => { | ||
const getUnionForSubState = (subState: SubState, depth = 0): string => { | ||
// Do not include sibling states in the union | ||
// if it's the root | ||
const states: string[] = | ||
depth === 0 | ||
? [] | ||
: Object.keys(subState.states).map((state) => `'${state}'`); | ||
|
||
const substatesWithChildren = Object.entries(subState.states).filter( | ||
([, value]) => { | ||
return Object.keys(value.states).length > 0; | ||
}, | ||
); | ||
|
||
if (substatesWithChildren.length > 0) { | ||
states.push( | ||
`{ ${substatesWithChildren | ||
.map(([state, value]) => { | ||
return `${state}?: ${getUnionForSubState(value, depth + 1)};`; | ||
}) | ||
.join("\n")} }`, | ||
); | ||
} | ||
return `${states.join(" | ")}`; | ||
}; | ||
|
||
return getUnionForSubState(introspectionResult.subState); | ||
}; |
Oops, something went wrong.