Skip to content

Commit

Permalink
feat: remove extension titles (#40)
Browse files Browse the repository at this point in the history
sourcegraph/sourcegraph#1613 eliminates extension titles; the extension ID is used instead. This commit makes the extension creator not ask for or write a title.
  • Loading branch information
sqs authored Jan 3, 2019
1 parent 898daae commit 6c1af45
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ async function getHttpsGitRemoteUrl(): Promise<string | undefined> {
async function main(): Promise<void> {
console.log(['', 'Welcome to the Sourcegraph extension creator!', ''].join('\n'))

const schema = 'https://raw.githubusercontent.com/sourcegraph/sourcegraph/master/shared/src/schema/extension.schema.json'
const schema =
'https://raw.githubusercontent.com/sourcegraph/sourcegraph/master/shared/src/schema/extension.schema.json'
let name: string | undefined
let repository: Repository | undefined
let title: string | undefined
let description: string | undefined
let publisher: string | undefined
let license: string | undefined

try {
;({ name, title, description, publisher, repository, license } = JSON.parse(
await readFile('package.json', 'utf-8')
))
;({ name, description, publisher, repository, license } = JSON.parse(await readFile('package.json', 'utf-8')))
} catch (err) {
if (err.code !== 'ENOENT') {
throw err
Expand Down Expand Up @@ -76,16 +74,6 @@ async function main(): Promise<void> {
})
}

if (title) {
console.log(`Extension title is "${title}"`)
} else {
title =
'WIP: ' +
(await prompt.input({
message: 'What should the title of the extension be (Sentence case)?',
}))
}

if (description) {
console.log(`Description is "${description}"`)
} else {
Expand Down Expand Up @@ -175,10 +163,12 @@ async function main(): Promise<void> {
const packageJson: JsonSchemaForNpmPackageJsonFiles = {
$schema: schema,
name,
title,
description,
publisher,
activationEvents: ['*'],
wip: true,
categories: [],
tags: [],
contributes: {
actions: [],
menus: {
Expand Down Expand Up @@ -223,7 +213,7 @@ async function main(): Promise<void> {
" sourcegraph.languages.registerHoverProvider(['*'], {",
' provideHover: () => ({',
' contents: {',
` value: 'Hello world from ${title}! 🎉🎉🎉',`,
` value: 'Hello world from ${name}! 🎉🎉🎉',`,
' kind: sourcegraph.MarkupKind.Markdown',
' }',
' }),',
Expand Down Expand Up @@ -262,15 +252,15 @@ async function main(): Promise<void> {
} else {
console.log('📄 Adding README')
const readme = [
`# ${title} Sourcegraph extension`,
`# ${name} (Sourcegraph extension)`,
'',
description[description.length - 1] === '.' ? description : description + '.',
'',
].join('\n')
await writeFile('README.md', readme)
}

console.log('⚠️ Remove "WIP:" from the title when this extension is ready for use.')
console.log('⚠️ Remove `"wip": true` from the package.json when this extension is ready for use.')

setTimeout(() => process.exit(0), 100)
}
Expand Down

0 comments on commit 6c1af45

Please sign in to comment.