mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-10 10:15:31 +02:00
🚧 Process for setting up projects
Note that I am still working on a process for setting up the nessisary file structure
This commit is contained in:
parent
52b13eb00c
commit
49695449c7
12 changed files with 180 additions and 33 deletions
87
src/commands/setupProject.ts
Normal file
87
src/commands/setupProject.ts
Normal file
|
@ -0,0 +1,87 @@
|
|||
import { writeFileSync, existsSync } from 'fs'
|
||||
|
||||
import prompts from 'prompts'
|
||||
|
||||
import { log } from '..'
|
||||
import { Config, configPath, getLatestFF, SupportedProducts } from '../utils'
|
||||
|
||||
const sleep = (time: number) => new Promise<void>((r) => setTimeout(r, time))
|
||||
|
||||
export async function setupProject() {
|
||||
if (existsSync(configPath)) {
|
||||
log.warning('There is already a config file. This will overwrite it!')
|
||||
await sleep(1000)
|
||||
}
|
||||
|
||||
// Ask user for assorted information
|
||||
const { product } = await prompts({
|
||||
type: 'select',
|
||||
name: 'product',
|
||||
message: 'Select a product to fork',
|
||||
choices: [
|
||||
{ title: 'Firefox stable', value: SupportedProducts.Firefox },
|
||||
{
|
||||
title: 'Firefox extended support (older)',
|
||||
value: SupportedProducts.FirefoxESR,
|
||||
},
|
||||
{
|
||||
title: 'Firefox extended support (newer)',
|
||||
value: SupportedProducts.FirefoxESRNext,
|
||||
},
|
||||
{
|
||||
title: 'Firefox developer edition (Not recommended)',
|
||||
value: SupportedProducts.FirefoxDev,
|
||||
},
|
||||
{
|
||||
title: 'Firefox beta (Not recommended)',
|
||||
value: SupportedProducts.FirefoxBeta,
|
||||
},
|
||||
{
|
||||
title: 'Firefox Nightly (Not recommended)',
|
||||
value: SupportedProducts.FirefoxNightly,
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
if (typeof product == 'undefined') return
|
||||
|
||||
const productVersion = await getLatestFF(product)
|
||||
|
||||
const { version, name, appId, vendor } = await prompts([
|
||||
{
|
||||
type: 'text',
|
||||
name: 'version',
|
||||
message: 'Enter the version of this product',
|
||||
initial: productVersion,
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'name',
|
||||
message: 'Enter a product name',
|
||||
initial: 'Example browser',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'vendor',
|
||||
message: 'Enter a vendor',
|
||||
initial: 'Example company',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'appId',
|
||||
message: 'Enter an appid',
|
||||
initial: 'com.example.browser',
|
||||
// Horrible validation to make sure people don't chose something entirely wrong
|
||||
validate: (t: string) => t.includes('.'),
|
||||
},
|
||||
])
|
||||
|
||||
const config: Config = {
|
||||
name,
|
||||
vendor,
|
||||
appId,
|
||||
version: { product, version, displayVersion: '1.0.0' },
|
||||
}
|
||||
|
||||
writeFileSync(configPath, JSON.stringify(config, null, 2))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue