@zeplin/cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@zeplin/cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Zeplin CLI", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/app", |
@@ -45,2 +45,10 @@ "use strict"; | ||
}); | ||
const bitbucketConfigSchema = joi_1.default.object({ | ||
repository: joi_1.default.string(), | ||
branch: joi_1.default.string().optional(), | ||
url: joi_1.default.string().optional(), | ||
path: joi_1.default.string().optional(), | ||
project: joi_1.default.string().optional(), | ||
user: joi_1.default.string().optional() | ||
}).xor("project", "user"); | ||
const pluginSchema = joi_1.default.object({ | ||
@@ -58,3 +66,3 @@ name: joi_1.default.string(), | ||
gitlab: gitConfigSchema.optional(), | ||
bitbucket: gitConfigSchema.optional() | ||
bitbucket: bitbucketConfigSchema.optional() | ||
}).custom((value, helpers) => { | ||
@@ -61,0 +69,0 @@ if (value.projects && value.styleguides) { |
@@ -104,2 +104,30 @@ "use strict"; | ||
}; | ||
const createBitbucketLink = (componentPath, bitbucketConfig) => { | ||
const { url = defaults_1.defaults.bitbucket.url, repository, branch = "", project = "", user = "", path: basePath = "" } = bitbucketConfig; | ||
const isCloud = url === defaults_1.defaults.bitbucket.url; | ||
const filePath = componentPath.split(path_1.default.sep); | ||
let preparedUrl; | ||
if (isCloud) { | ||
const prefix = defaults_1.defaults.bitbucket.cloudPrefix; | ||
preparedUrl = url_join_1.default(url, user, repository, prefix, branch, basePath, ...filePath); | ||
} | ||
else if (!project && !user) { | ||
// Backward compatibility | ||
// TODO: remove this block after a while | ||
preparedUrl = url_join_1.default(url, repository, branch, basePath, ...filePath); | ||
} | ||
else { | ||
const owner = project | ||
? { path: "projects", name: project } | ||
: { path: "users", name: user }; | ||
preparedUrl = url_join_1.default(url, owner.path, owner.name, "repos", repository, "browse", basePath, ...filePath); | ||
if (branch) { | ||
preparedUrl += `?at=${branch}`; | ||
} | ||
} | ||
return { | ||
type: defaults_1.defaults.bitbucket.type, | ||
url: encodeURI(preparedUrl) | ||
}; | ||
}; | ||
const createRepoLinks = (componentPath, componentConfigFile) => { | ||
@@ -114,3 +142,3 @@ const repoLinks = []; | ||
if (componentConfigFile.bitbucket) { | ||
repoLinks.push(createRepoLink(componentPath, componentConfigFile.bitbucket, defaults_1.defaults.bitbucket)); | ||
repoLinks.push(createBitbucketLink(componentPath, componentConfigFile.bitbucket)); | ||
} | ||
@@ -117,0 +145,0 @@ return repoLinks; |
@@ -29,6 +29,5 @@ import { LinkType } from "../commands/connect/interfaces/plugin"; | ||
url: string; | ||
branch: string; | ||
prefix: string; | ||
cloudPrefix: string; | ||
type: LinkType; | ||
}; | ||
}; |
@@ -30,4 +30,3 @@ "use strict"; | ||
url: "https://bitbucket.org", | ||
branch: "master", | ||
prefix: "/src/", | ||
cloudPrefix: "/src/", | ||
type: "bitbucket" /* bitbucket */ | ||
@@ -34,0 +33,0 @@ } |
/** @public */ | ||
export declare interface BitbucketConfig extends GitConfig { | ||
/** Project name that the repo belongs to */ | ||
project?: string; | ||
/** User name that the repo belongs to*/ | ||
user?: string; | ||
} | ||
/** | ||
@@ -59,3 +67,3 @@ * Union of {@link ComponentConfigBase} and {@link ComponentConfigCustom} | ||
github?: GitConfig; | ||
bitbucket?: GitConfig; | ||
bitbucket?: BitbucketConfig; | ||
gitlab?: GitConfig; | ||
@@ -62,0 +70,0 @@ } |
@@ -10,3 +10,3 @@ <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
```typescript | ||
bitbucket?: GitConfig; | ||
bitbucket?: BitbucketConfig; | ||
``` |
@@ -19,3 +19,3 @@ <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
| --- | --- | --- | | ||
| [bitbucket](./cli.componentconfigfile.bitbucket.md) | <code>GitConfig</code> | | | ||
| [bitbucket](./cli.componentconfigfile.bitbucket.md) | <code>BitbucketConfig</code> | | | ||
| [components](./cli.componentconfigfile.components.md) | <code>ComponentConfig[]</code> | Union of [ComponentConfigBase](./cli.componentconfigbase.md) and [ComponentConfigCustom](./cli.componentconfigcustom.md) | | ||
@@ -22,0 +22,0 @@ | [github](./cli.componentconfigfile.github.md) | <code>GitConfig</code> | [GitConfig](./cli.gitconfig.md) | |
@@ -18,2 +18,3 @@ <!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
| --- | --- | | ||
| [BitbucketConfig](./cli.bitbucketconfig.md) | | | ||
| [ComponentConfigBase](./cli.componentconfigbase.md) | Contains basic configuration for a component. | | ||
@@ -20,0 +21,0 @@ | [ComponentConfigCustom](./cli.componentconfigcustom.md) | Custom key/value configuration for a component. Can be used to compose custom links for components or can be processed by plugins for custom usage. | |
{ | ||
"name": "@zeplin/cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Zeplin CLI", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/app", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229732
135
4152