Skip to content

Commit

Permalink
Add support for organizations, release v1.10.0 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
apai4 authored May 8, 2024
1 parent 6d73e9a commit b55124d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# @stackblitz/sdk changelog

## v1.10.0 (2024-05-03)
- Added support for `organization` in `ProjectOptions`

## v1.9.0 (2023-04-04)

- Moved the StackBlitz SDK to a dedicated repository: https://github.com/stackblitz/sdk.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stackblitz/sdk",
"version": "1.9.0",
"version": "1.10.0",
"description": "SDK for generating and embedding StackBlitz projects.",
"license": "MIT",
"author": "Eric Simons",
Expand Down
15 changes: 12 additions & 3 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ export interface ProjectOptions {
* Defaults to `https://stackblitz.com`.
*/
origin?: string;
/**
* Set the organization where you want to run the project.
*
* Defaults to no organization.
*/
organization?: {
provider: 'github';
name: string;
}
/**
* Show the sidebar as open or closed on page load.
*
Expand All @@ -121,7 +130,7 @@ export interface ProjectOptions {
* Choose the sidebar view to open on project load.
*
* Available views: `project` (default), `search`, `ports` (WebContainers only) and `settings`.
*
*
* @since 1.9.0
*/
sidebarView?: UiSidebarView;
Expand All @@ -140,7 +149,7 @@ export interface ProjectOptions {
* startScript: 'build,serve'
*
* Defaults to looking for a `dev` script or a `start` script. Ignored in EngineBlock projects.
*
*
* @since 1.9.0
*/
startScript?: string;
Expand Down Expand Up @@ -177,7 +186,7 @@ export interface OpenOptions extends ProjectOptions {
* Opens the project with the editor UI partially hidden (known as “zen mode”).
*
* Defaults to `false`.
*
*
* @since 1.9.0
*/
zenMode?: boolean;
Expand Down
5 changes: 4 additions & 1 deletion src/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ type ParamName =
| 'terminalHeight'
| 'theme'
| 'view'
| 'zenMode';
| 'zenMode'
| 'orgName'
| 'orgProvider';

export const generators: Record<keyof ParamOptions, (value: any) => string> = {
clickToLoad: (value: ParamOptions['clickToLoad']) => trueParam('ctl', value),
Expand All @@ -54,6 +56,7 @@ export const generators: Record<keyof ParamOptions, (value: any) => string> = {
theme: (value: ParamOptions['theme']) => enumParam('theme', value, UI_THEMES),
view: (value: ParamOptions['view']) => enumParam('view', value, UI_VIEWS),
zenMode: (value: ParamOptions['zenMode']) => trueParam('zenMode', value),
organization: (value: ParamOptions['organization']) => `${stringParams('orgName', value?.name)}&${stringParams('orgProvider', value?.provider)}`,
};

export function buildParams(options: ParamOptions = {}): string {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/params.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('buildParams', () => {
hideExplorer: false,
hideNavigation: false,
openFile: '',
organization: undefined,
showSidebar: undefined,
sidebarView: 'default',
startScript: undefined,
Expand All @@ -107,6 +108,7 @@ describe('buildParams', () => {
hideExplorer: true,
hideNavigation: true,
openFile: ['src/index.js,src/styles.css', 'package.json'],
organization: {name: 'stackblitz', provider: 'github'},
showSidebar: true,
sidebarView: 'search',
startScript: 'dev:serve',
Expand All @@ -129,6 +131,8 @@ describe('buildParams', () => {
'hideNavigation=1',
'file=src%2Findex.js%2Csrc%2Fstyles.css',
'file=package.json',
'orgName=stackblitz',
'orgProvider=github',
'showSidebar=1',
'sidebarView=search',
'startScript=dev%3Aserve',
Expand Down

0 comments on commit b55124d

Please sign in to comment.