Skip to content

Commit

Permalink
fix: Adding snapStore to AllPublishOptions for generating Configurati…
Browse files Browse the repository at this point in the history
…on schema (#6193)
  • Loading branch information
mmaietta committed Aug 27, 2021
1 parent a755c82 commit 7f933d0
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 55 deletions.
6 changes: 6 additions & 0 deletions .changeset/tough-seahorses-prove.md
@@ -0,0 +1,6 @@
---
"app-builder-lib": patch
"builder-util-runtime": patch
---

fix: adding snapStore to AllPublishOptions so that it properly is generated via `pnpm schema`
75 changes: 40 additions & 35 deletions packages/app-builder-lib/scheme.json
Expand Up @@ -1522,12 +1522,23 @@
"type": "string"
},
"channel": {
"anyOf": [
{
"enum": [
"alpha",
"beta",
"dev",
"rc",
"stable"
],
"type": "string"
},
{
"type": "null"
}
],
"default": "stable",
"description": "The channel.",
"type": [
"null",
"string"
]
"description": "The channel."
},
"platform": {
"description": "The target Platform. Is set programmatically explicitly during publishing.",
Expand Down Expand Up @@ -4702,19 +4713,6 @@
],
"type": "object"
},
"PublishProvider": {
"enum": [
"bintray",
"custom",
"generic",
"github",
"keygen",
"s3",
"snapStore",
"spaces"
],
"type": "string"
},
"ReleaseInfo": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -5254,8 +5252,11 @@
"description": "The list of channels the snap would be released."
},
"provider": {
"$ref": "#/definitions/PublishProvider",
"description": "The provider."
"description": "The provider. Must be `snapStore`.",
"enum": [
"snapStore"
],
"type": "string"
},
"publishAutoUpdate": {
"default": true,
Expand All @@ -5275,6 +5276,10 @@
}
]
},
"repo": {
"description": "snapcraft repo name",
"type": "string"
},
"requestHeaders": {
"$ref": "#/definitions/OutgoingHttpHeaders",
"description": "Any custom request headers"
Expand All @@ -5287,7 +5292,8 @@
}
},
"required": [
"provider"
"provider",
"repo"
],
"type": "object"
},
Expand Down Expand Up @@ -6025,20 +6031,6 @@
],
"description": "The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild)."
},
"beforePack": {
"anyOf": [
{
"typeof": "function"
},
{
"type": [
"null",
"string"
]
}
],
"description": "The function (or path to file or module id) to be [run before pack](#beforepack)"
},
"afterPack": {
"anyOf": [
{
Expand Down Expand Up @@ -6201,6 +6193,19 @@
],
"description": "The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.\n\nIf provided and `node_modules` are missing, it will not invoke production dependencies check."
},
"beforePack": {
"anyOf": [
{
"typeof": "function"
},
{
"type": [
"null",
"string"
]
}
]
},
"buildDependenciesFromSource": {
"default": false,
"description": "Whether to build the application native dependencies from source.",
Expand Down
3 changes: 3 additions & 0 deletions packages/app-builder-lib/src/configuration.ts
Expand Up @@ -195,6 +195,9 @@ export interface Configuration extends PlatformSpecificBuildOptions {
*/
readonly framework?: string | null

/**
* The function (or path to file or module id) to be [run before pack](#beforepack)
*/
readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/app-builder-lib/src/core.ts
@@ -1,9 +1,8 @@
import { Arch, archFromString, ArchType } from "builder-util"
import { AllPublishOptions } from "builder-util-runtime"
import { SnapStoreOptions } from "./publish/SnapStorePublisher"

// https://github.com/YousefED/typescript-json-schema/issues/80
export type Publish = AllPublishOptions | SnapStoreOptions | Array<AllPublishOptions | SnapStoreOptions> | null
export type Publish = AllPublishOptions | Array<AllPublishOptions> | null

export type TargetConfigType = Array<string | TargetConfiguration> | string | TargetConfiguration | null

Expand Down
1 change: 0 additions & 1 deletion packages/app-builder-lib/src/index.ts
Expand Up @@ -52,7 +52,6 @@ export { PublishManager } from "./publish/PublishManager"
export { PlatformPackager } from "./platformPackager"
export { Framework, PrepareApplicationStageDirectoryOptions } from "./Framework"
export { buildForge, ForgeOptions } from "./forge-maker"
export { SnapStoreOptions } from "./publish/SnapStorePublisher"

const expectedOptions = new Set(["publish", "targets", "mac", "win", "linux", "projectDir", "platformPackagerFactory", "config", "effectiveOptionComputed", "prepackaged"])

Expand Down
3 changes: 2 additions & 1 deletion packages/app-builder-lib/src/publish/PublishManager.ts
Expand Up @@ -8,6 +8,7 @@ import {
GithubOptions,
githubUrl,
KeygenOptions,
SnapStoreOptions,
PublishConfiguration,
PublishProvider,
} from "builder-util-runtime"
Expand All @@ -28,7 +29,7 @@ import { Packager } from "../packager"
import { PlatformPackager } from "../platformPackager"
import { expandMacro } from "../util/macroExpander"
import { WinPackager } from "../winPackager"
import { SnapStoreOptions, SnapStorePublisher } from "./SnapStorePublisher"
import { SnapStorePublisher } from "./SnapStorePublisher"
import { createUpdateInfoTasks, UpdateInfoFileTask, writeUpdateInfoFiles } from "./updateInfoBuilder"
import { KeygenPublisher } from "./KeygenPublisher"

Expand Down
13 changes: 1 addition & 12 deletions packages/app-builder-lib/src/publish/SnapStorePublisher.ts
@@ -1,7 +1,7 @@
import { Publisher, UploadTask, PublishContext } from "electron-publish"
import { executeAppBuilder } from "builder-util"
import * as path from "path"
import { PublishConfiguration } from "builder-util-runtime"
import { SnapStoreOptions } from "builder-util-runtime/out/publishOptions"

export class SnapStorePublisher extends Publisher {
readonly providerName = "snapStore"
Expand Down Expand Up @@ -35,14 +35,3 @@ export class SnapStorePublisher extends Publisher {
return "Snap Store"
}
}

/**
* [Snap Store](https://snapcraft.io/) options.
*/
export interface SnapStoreOptions extends PublishConfiguration {
/**
* The list of channels the snap would be released.
* @default ["edge"]
*/
readonly channels?: string | Array<string> | null
}
1 change: 0 additions & 1 deletion packages/app-builder-lib/src/version.ts
@@ -1,2 +1 @@

export const PACKAGE_VERSION = "22.13.0"
1 change: 1 addition & 0 deletions packages/builder-util-runtime/src/index.ts
Expand Up @@ -19,6 +19,7 @@ export {
GenericServerOptions,
GithubOptions,
KeygenOptions,
SnapStoreOptions,
PublishConfiguration,
S3Options,
SpacesOptions,
Expand Down
23 changes: 22 additions & 1 deletion packages/builder-util-runtime/src/publishOptions.ts
Expand Up @@ -3,7 +3,7 @@ import { OutgoingHttpHeaders } from "http"
export type PublishProvider = "github" | "bintray" | "s3" | "spaces" | "generic" | "custom" | "snapStore" | "keygen"

// typescript-json-schema generates only PublishConfiguration if it is specified in the list, so, it is not added here
export type AllPublishOptions = string | GithubOptions | S3Options | SpacesOptions | GenericServerOptions | BintrayOptions | CustomPublishOptions | KeygenOptions
export type AllPublishOptions = string | GithubOptions | S3Options | SpacesOptions | GenericServerOptions | BintrayOptions | CustomPublishOptions | KeygenOptions | SnapStoreOptions

export interface PublishConfiguration {
/**
Expand Down Expand Up @@ -179,6 +179,27 @@ export interface KeygenOptions extends PublishConfiguration {
readonly platform?: string | null
}

/**
* [Snap Store](https://snapcraft.io/) options.
*/
export interface SnapStoreOptions extends PublishConfiguration {
/**
* The provider. Must be `snapStore`.
*/
readonly provider: "snapStore"

/**
* snapcraft repo name
*/
readonly repo: string

/**
* The list of channels the snap would be released.
* @default ["edge"]
*/
readonly channels?: string | Array<string> | null
}

export interface BaseS3Options extends PublishConfiguration {
/**
* The update channel.
Expand Down
3 changes: 1 addition & 2 deletions scripts/update-package-version-export.js
Expand Up @@ -4,6 +4,5 @@ const version = require(path.join(__dirname, "../packages/app-builder-lib/packag
const destFile = path.join(__dirname, '../packages/app-builder-lib/src/version.ts')

const { writeFileSync } = require("fs")
writeFileSync(destFile, `
export const PACKAGE_VERSION = "${version}"
writeFileSync(destFile, `export const PACKAGE_VERSION = "${version}"
`)

0 comments on commit 7f933d0

Please sign in to comment.