lib/setup.js
function wizardSetup (program) {
  const welcome = multiline.stripIndent(function () { /*
        Welcome to the Electron-Windows-Store tool!

        This tool will assist you with turning your Electron app into
        a swanky Windows Store app.

        We need to know some settings. We will ask you only once and store
        your answers in your profile folder in a .electron-windows-store
        file.

    */
  })
  const complete = multiline.stripIndent(function () { /*

        Setup complete, moving on to package your app!

    */
  })

  let questions = [
    {
      name: 'desktopConverter',
      type: 'input',
      message: 'Please enter the path to your Desktop App Converter (DesktopAppConverter.ps1): ',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.desktopConverter)
    },
    {
      name: 'expandedBaseImage',
      type: 'input',
      message: 'Please enter the path to your Expanded Base Image: ',
      default: 'C:\\ProgramData\\Microsoft\\Windows\\Images\\BaseImage-14316\\',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.expandedBaseImage)
    },
    {
      name: 'devCert',
      type: 'input',
      message: 'Please enter the path to your development PFX certficate: ',
      default: null,
      when: () => (!dotfile.get().makeCertificate || !program.devCert)
    },
    {
      name: 'publisher',
      type: 'input',
      message: 'Please enter your publisher identity: ',
      default: 'CN=developmentca',
      when: () => (!program.publisher)
    },
    {
      name: 'windowsKit',
      type: 'input',
      message: "Please enter the location of your Windows Kit's bin folder: ",
      default: utils.getDefaultWindowsKitLocation(),
      when: () => (!program.windowsKit)
    }
  ]

  if (!program.isModuleUse) {
    utils.log(welcome)
  }

  // Remove the Desktop Converter Questions if not installed
  if (program.didInstallDesktopAppConverter === false) {
    questions = questions.slice(3)
  }

  if (program.isModuleUse) {
    program.windowsKit = program.windowsKit || utils.getDefaultWindowsKitLocation()

    return Promise.resolve(program)
  }

  return inquirer.prompt(questions)
    .then((answers) => {
      dotfile.set({
        desktopConverter: answers.desktopConverter || false,
        expandedBaseImage: answers.expandedBaseImage || false,
        devCert: answers.devCert,
        publisher: answers.publisher,
        windowsKit: answers.windowsKit,
        makeCertificate: dotfile.get().makeCertificate
      })

      program.desktopConverter = answers.desktopConverter
      program.expandedBaseImage = answers.expandedBaseImage
      program.devCert = answers.devCert
      program.publisher = answers.publisher
      program.windowsKit = answers.windowsKit

      if (program.makeCertificate) {
        utils.log(chalk.bold.green('Creating Certficate'))
        let publisher = dotfile.get().publisher.split('=')[1]
        let certFolder = path.join(process.env.APPDATA, 'electron-windows-store', publisher)

        return sign.makeCert({ publisherName: publisher, certFilePath: certFolder, program: program })
          .then(pfxFile => {
            utils.log('Created and installed certificate:')
            utils.log(pfxFile)
            dotfile.set({ devCert: pfxFile })
          })
      }

      utils.log(complete)
    })
}
function wizardSetup (program) {
  const welcome = multiline.stripIndent(function () { /*
        Welcome to the Electron-Windows-Store tool!

        This tool will assist you with turning your Electron app into
        a swanky Windows Store app.

        We need to know some settings. We will ask you only once and store
        your answers in your profile folder in a .electron-windows-store
        file.

    */
  })
  const complete = multiline.stripIndent(function () { /*

        Setup complete, moving on to package your app!

    */
  })

  let questions = [
    {
      name: 'desktopConverter',
      type: 'input',
      message: 'Please enter the path to your Desktop App Converter (DesktopAppConverter.ps1): ',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.desktopConverter)
    },
    {
      name: 'expandedBaseImage',
      type: 'input',
      message: 'Please enter the path to your Expanded Base Image: ',
      default: 'C:\\ProgramData\\Microsoft\\Windows\\Images\\BaseImage-14316\\',
      validate: (input) => pathExists.sync(input),
      when: () => (!program.expandedBaseImage)
    },
    {
      name: 'devCert',
      type: 'input',
      message: 'Please enter the path to your development PFX certficate: ',
      default: null,
      when: () => (!dotfile.get().makeCertificate || !program.devCert)
    },
    {
      name: 'publisher',
      type: 'input',
      message: 'Please enter your publisher identity: ',
      default: 'CN=developmentca',
      when: () => (!program.publisher)
    },
    {
      name: 'windowsKit',
      type: 'input',
      message: "Please enter the location of your Windows Kit's bin folder: ",
      default: utils.getDefaultWindowsKitLocation(),
      when: () => (!program.windowsKit)
    }
  ]

  if (!program.isModuleUse) {
    utils.log(welcome)
  }

  // Remove the Desktop Converter Questions if not installed
  if (program.didInstallDesktopAppConverter === false) {
    questions = questions.slice(3)
  }

  if (program.isModuleUse) {
    program.windowsKit = program.windowsKit || utils.getDefaultWindowsKitLocation()

    return Promise.resolve(program)
  }

  return inquirer.prompt(questions)
    .then((answers) => {
      dotfile.set({
        desktopConverter: answers.desktopConverter || false,
        expandedBaseImage: answers.expandedBaseImage || false,
        devCert: answers.devCert,
        publisher: answers.publisher,
        windowsKit: answers.windowsKit,
        makeCertificate: dotfile.get().makeCertificate
      })

      program.desktopConverter = answers.desktopConverter
      program.expandedBaseImage = answers.expandedBaseImage
      program.devCert = answers.devCert
      program.publisher = answers.publisher
      program.windowsKit = answers.windowsKit

      if (program.makeCertificate) {
        utils.log(chalk.bold.green('Creating Certficate'))
        let publisher = dotfile.get().publisher.split('=')[1]
        let certFolder = path.join(process.env.APPDATA, 'electron-windows-store', publisher)

        return sign.makeCert({ publisherName: publisher, certFilePath: certFolder, program: program })
          .then(pfxFile => {
            utils.log('Created and installed certificate:')
            utils.log(pfxFile)
            dotfile.set({ devCert: pfxFile })
          })
      }

      utils.log(complete)
    })
}
function wizardSetup ( program ) { const welcome = multiline . stripIndent ( function ( ) { /*
        Welcome to the Electron-Windows-Store tool!

        This tool will assist you with turning your Electron app into
        a swanky Windows Store app.

        We need to know some settings. We will ask you only once and store
        your answers in your profile folder in a .electron-windows-store
        file.

    */ } ) const complete = multiline . stripIndent ( function ( ) { /*

        Setup complete, moving on to package your app!

    */ } ) let questions = [ { name : 'desktopConverter' , type : 'input' , message : 'Please enter the path to your Desktop App Converter (DesktopAppConverter.ps1): ' , validate : ( input ) => pathExists . sync ( input ) , when : ( ) => ( ! program . desktopConverter ) } , { name : 'expandedBaseImage' , type : 'input' , message : 'Please enter the path to your Expanded Base Image: ' , default : 'C:\\ProgramData\\Microsoft\\Windows\\Images\\BaseImage-14316\\' , validate : ( input ) => pathExists . sync ( input ) , when : ( ) => ( ! program . expandedBaseImage ) } , { name : 'devCert' , type : 'input' , message : 'Please enter the path to your development PFX certficate: ' , default : null , when : ( ) => ( ! dotfile . get ( ) . makeCertificate || ! program . devCert ) } , { name : 'publisher' , type : 'input' , message : 'Please enter your publisher identity: ' , default : 'CN=developmentca' , when : ( ) => ( ! program . publisher ) } , { name : 'windowsKit' , type : 'input' , message : "Please enter the location of your Windows Kit's bin folder: " , default : utils . getDefaultWindowsKitLocation ( ) , when : ( ) => ( ! program . windowsKit ) } ] if ( ! program . isModuleUse ) { utils . log ( welcome ) } // Remove the Desktop Converter Questions if not installed if ( program . didInstallDesktopAppConverter === false ) { questions = questions . slice ( 3 ) } if ( program . isModuleUse ) { program . windowsKit = program . windowsKit || utils . getDefaultWindowsKitLocation ( ) return Promise . resolve ( program ) } return inquirer . prompt ( questions ) . then ( ( answers ) => { dotfile . set ( { desktopConverter : answers . desktopConverter || false , expandedBaseImage : answers . expandedBaseImage || false , devCert : answers . devCert , publisher : answers . publisher , windowsKit : answers . windowsKit , makeCertificate : dotfile . get ( ) . makeCertificate } ) program . desktopConverter = answers . desktopConverter program . expandedBaseImage = answers . expandedBaseImage program . devCert = answers . devCert program . publisher = answers . publisher program . windowsKit = answers . windowsKit if ( program . makeCertificate ) { utils . log ( chalk . bold . green ( 'Creating Certficate' ) ) let publisher = dotfile . get ( ) . publisher . split ( '=' ) [ 1 ] let certFolder = path . join ( process . env . APPDATA , 'electron-windows-store' , publisher ) return sign . makeCert ( { publisherName : publisher , certFilePath : certFolder , program : program } ) . then ( pfxFile => { utils . log ( 'Created and installed certificate:' ) utils . log ( pfxFile ) dotfile . set ( { devCert : pfxFile } ) } ) } utils . log ( complete ) } ) }
Runs a wizard, helping the user setup configuration

@param program - Commander program object
@returns {Promise} - Promsise that returns once wizard completed
Runs a wizard helping the user setup configuration