Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: new template format for stable channels
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 9, 2018
1 parent b8cce0f commit 1f27a10
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
"@types/chai": "^4.1.2",
"@types/globby": "^6.1.0",
"@types/indent-string": "^3.0.0",
"@types/lodash": "^4.14.106",
"@types/mocha": "^5.0.0",
"@types/node": "^9.6.2",
"@types/wrap-ansi": "^3.0.0",
"chai": "^4.1.2",
"fancy-test": "^1.0.4",
"globby": "^8.0.1",
"lodash": "^4.17.5",
"mocha": "^5.0.5",
"ts-node": "^5.0.1",
"tslint": "^5.9.1",
Expand Down
8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ export class Config implements IConfig {
s3.templates = {
platformBaseDir: '<%- bin %>',
vanillaBaseDir: '<%- bin %>',
platformTarball: '<%- name %>/channels/<%- channel %>/<%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %>',
vanillaTarball: '<%- name %>/channels/<%- channel %>/<%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>',
platformManifest: '<%- name %>/channels/<%- channel %>/<%- platform %>-<%- arch %>',
vanillaManifest: '<%- name %>/channels/<%- channel %>/version',
platformTarball: "<%- name %><%- channel === 'stable' ? '' : '/channels/' + channel %>/<%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %>",
vanillaTarball: "<%- name %><%- channel === 'stable' ? '' : '/channels/' + channel %>/<%- bin %>-v<%- version %>/<%- bin %>-v<%- version %>",
platformManifest: "<%- name %><%- channel === 'stable' ? '' : '/channels/' + channel %>/<%- platform %>-<%- arch %>",
vanillaManifest: "<%- name %><%- channel === 'stable' ? '' : '/channels/' + channel %>/version",
...s3.templates,
}

Expand Down
19 changes: 19 additions & 0 deletions test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as _ from 'lodash'
import * as os from 'os'
import * as path from 'path'

Expand All @@ -20,6 +21,24 @@ describe('PluginConfig', () => {
dataDir: path.join('/my/home/.local/share/@oclif/config'),
home: path.join('/my/home'),
})
const checkTemplate = (k: keyof Config.PJSON.Plugin['oclif']['update']['s3']['templates'], expected: string, extra: any = {}) => {
expect(_.template(config.pjson.oclif.update.s3.templates[k])({
...config,
bin: 'oclif-cli',
version: '1.0.0',
...extra
})).to.equal(expected)
}
checkTemplate('platformBaseDir', 'oclif-cli')
checkTemplate('vanillaBaseDir', 'oclif-cli')
checkTemplate('platformTarball', '@oclif/config/oclif-cli-v1.0.0/oclif-cli-v1.0.0-darwin-x64')
checkTemplate('platformManifest', '@oclif/config/darwin-x64')
checkTemplate('vanillaManifest', '@oclif/config/version')
checkTemplate('vanillaTarball', '@oclif/config/channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta', {version: '2.0.0-beta', channel: 'beta'})
checkTemplate('platformTarball', '@oclif/config/channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta-darwin-x64', {version: '2.0.0-beta', channel: 'beta'})
checkTemplate('platformManifest', '@oclif/config/channels/beta/darwin-x64', {version: '2.0.0-beta', channel: 'beta'})
checkTemplate('vanillaManifest', '@oclif/config/channels/beta/version', {version: '2.0.0-beta', channel: 'beta'})
checkTemplate('vanillaTarball', '@oclif/config/channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta', {version: '2.0.0-beta', channel: 'beta'})
})

fancy
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/indent-string/-/indent-string-3.0.0.tgz#9ebb391ceda548926f5819ad16405349641b999f"

"@types/lodash@^4.14.106":
version "4.14.106"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.106.tgz#6093e9a02aa567ddecfe9afadca89e53e5dce4dd"

"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
Expand Down

0 comments on commit 1f27a10

Please sign in to comment.