Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump SDK, add page drafts support #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"printWidth": 120,
"arrowParens": "avoid",
"tabWidth": 4
"printWidth": 120,
"arrowParens": "avoid",
"semi": false,
"tabWidth": 2
}
23 changes: 12 additions & 11 deletions package-lock.json

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

216 changes: 108 additions & 108 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
{
"name": "@supernovaio/cli",
"description": "Supernova.io Command Line Interface",
"version": "1.1.0",
"author": "Supernova.io",
"homepage": "https://supernova.io/",
"keywords": [
"Supernova",
"Design Systems",
"Supernovaio",
"SDK",
"Design Tokens",
"Tokens",
"Assets",
"Components",
"Documentation",
"CMS"
"name": "@supernovaio/cli",
"description": "Supernova.io Command Line Interface",
"version": "1.1.1",
"author": "Supernova.io",
"homepage": "https://supernova.io/",
"keywords": [
"Supernova",
"Design Systems",
"Supernovaio",
"SDK",
"Design Tokens",
"Tokens",
"Assets",
"Components",
"Documentation",
"CMS"
],
"license": "MIT",
"bin": {
"supernova": "./bin/run"
},
"bugs": "https://github.com/Supernova-Studio/cli/issues",
"dependencies": {
"@oclif/core": "4.0.17",
"@oclif/plugin-help": "6.2.8",
"@oclif/plugin-plugins": "5.4.2",
"@supernova-studio/pulsar-core": "2.3.21",
"@supernovaio/sdk": "^2.0.27",
"axios": "^1.7.7",
"colors": "^1.4.0",
"minimatch": "^9.0.5",
"node-fetch": "^3.2.4"
},
"bundleDependencies": [
"@supernova-studio/pulsar-core",
"@supernova-studio/simple-parse-github-url",
"@supernova-studio/client",
"@supernova-studio/model"
],
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "7.18.6",
"@babel/register": "^7.18.9",
"@oclif/test": "4.0.8",
"@types/chai": "^4",
"@types/colors": "^1.2.1",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.36",
"chai": "^4",
"dotenv": "^16.0.0",
"eslint": "^7.32.0",
"eslint-config-oclif": "^5.2.1",
"eslint-config-oclif-typescript": "^3.1.9",
"globby": "^11",
"mocha": "^9",
"oclif": "4.14.15",
"shx": "^0.3.3",
"ts-node": "10.9.1",
"tslib": "^2.3.1",
"typescript": "5.2.2"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"/bin",
"/dist",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"main": "dist/index.js",
"oclif": {
"bin": "supernova",
"dirname": "supernova",
"commands": "./dist/commands",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins"
],
"license": "MIT",
"bin": {
"supernova": "./bin/run"
},
"bugs": "https://github.com/Supernova-Studio/cli/issues",
"dependencies": {
"@oclif/core": "4.0.17",
"@oclif/plugin-help": "6.2.8",
"@oclif/plugin-plugins": "5.4.2",
"@supernova-studio/pulsar-core": "2.3.21",
"@supernovaio/sdk": "2.0.12",
"axios": "^1.7.7",
"colors": "^1.4.0",
"minimatch": "^9.0.5",
"node-fetch": "^3.2.4"
},
"bundleDependencies": [
"@supernova-studio/pulsar-core",
"@supernova-studio/simple-parse-github-url",
"@supernova-studio/client",
"@supernova-studio/model"
],
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.3.4",
"@babel/preset-react": "7.18.6",
"@babel/register": "^7.18.9",
"@oclif/test": "4.0.8",
"@types/chai": "^4",
"@types/colors": "^1.2.1",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.36",
"chai": "^4",
"dotenv": "^16.0.0",
"eslint": "^7.32.0",
"eslint-config-oclif": "^5.2.1",
"eslint-config-oclif-typescript": "^3.1.9",
"globby": "^11",
"mocha": "^9",
"oclif": "4.14.15",
"shx": "^0.3.3",
"ts-node": "10.9.1",
"tslib": "^2.3.1",
"typescript": "5.2.2"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"/bin",
"/dist",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"main": "dist/index.js",
"oclif": {
"bin": "supernova",
"dirname": "supernova",
"commands": "./dist/commands",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins"
],
"topicSeparator": " ",
"topics": {
"sync-tokens": {
"description": "Synchronize tokens from Figma Tokens plugin to Supernova workspaces"
},
"describe-design-system": {
"description": "Describe structure (brands and themes) of selected design system"
},
"describe-workspaces": {
"description": "Describe structure of all workspaces provided API key has access to"
},
"publish-documentation": {
"description": "Publish current documentation"
},
"run-local-exporter": {
"description": "Run exporer package locally"
}
}
},
"repository": "https://github.com/Supernova-Studio/cli",
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"lint": "eslint . --ext .ts --config .eslintrc",
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "yarn build && oclif manifest",
"test": "DEBUG=* && npm run build && env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register --forbid-only \"test/**/sync-tokens.test.ts\"",
"publish-package": "npm run build && npm run prepack && npm publish --access public && npm run postpack"
},
"types": "dist/index.d.ts"
"topicSeparator": " ",
"topics": {
"sync-tokens": {
"description": "Synchronize tokens from Figma Tokens plugin to Supernova workspaces"
},
"describe-design-system": {
"description": "Describe structure (brands and themes) of selected design system"
},
"describe-workspaces": {
"description": "Describe structure of all workspaces provided API key has access to"
},
"publish-documentation": {
"description": "Publish current documentation"
},
"run-local-exporter": {
"description": "Run exporer package locally"
}
}
},
"repository": "https://github.com/Supernova-Studio/cli",
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"lint": "eslint . --ext .ts --config .eslintrc",
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "yarn build && oclif manifest",
"test": "DEBUG=* && npm run build && env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register --forbid-only \"test/**/sync-tokens.test.ts\"",
"publish-package": "npm run build && npm run prepack && npm publish --access public && npm run postpack"
},
"types": "dist/index.d.ts"
}
31 changes: 28 additions & 3 deletions src/commands/publish-documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Command, Flags } from "@oclif/core"
import { Environment, ErrorCode } from "../types/types"
import { getWritableVersion } from "../utils/sdk"
import "colors"
import { DocumentationEnvironment } from "@supernovaio/sdk"

// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
// MARK: - Definition
Expand Down Expand Up @@ -42,7 +43,11 @@ export class PublishDocumentation extends Command {
apiKey: Flags.string({ description: "API key to use for accessing Supernova instance", required: true }),
designSystemId: Flags.string({ description: "Design System to publish the documentation", required: true }),
dev: Flags.boolean({ description: "When enabled, CLI will target dev server", hidden: true, default: false }),
target: Flags.string({ description: "Environment to use for publishing: Live or Preview", required: false, default: "Live" }),
target: Flags.string({
description: "Environment to use for publishing: Live or Preview",
required: false,
default: "Live",
}),
environment: Flags.string({
description: "When set, CLI will target a specific environment",
hidden: true,
Expand All @@ -64,10 +69,18 @@ export class PublishDocumentation extends Command {
try {
const { flags } = await this.parse(PublishDocumentation)

const environment = tryParseDocsEnvironment(flags.target)
if (!environment) {
const supportedEnvs = [DocumentationEnvironment.live, DocumentationEnvironment.preview]
this.error(`Unknown target ${flags.target}, must be one of [${supportedEnvs.join(", ")}]`)
}

// Get workspace -> design system –> version
let { instance, id } = await getWritableVersion(flags)
let documentation = await instance.documentation.getDocumentation(id)
let result = await instance.documentation.publish(id, flags.target as any)
let result = await instance.documentation.publishDrafts(id, environment, {
pagePersistentIds: [],
groupPersistentIds: [],
})

if (result.status === "Success") {
this.log("\nDone: Documentation queued for publishing".green)
Expand All @@ -84,3 +97,15 @@ export class PublishDocumentation extends Command {
}
}
}

function tryParseDocsEnvironment(targetArg: string) {
switch (targetArg.toLowerCase()) {
case "live":
return DocumentationEnvironment.live
case "preview":
return DocumentationEnvironment.preview

default:
return null
}
}
Loading
Loading