rename targetDir to targetFolder in deploy config
This commit is contained in:
		
							parent
							
								
									98dede02b8
								
							
						
					
					
						commit
						2d28391d45
					
				
							
								
								
									
										42
									
								
								deploy.js
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								deploy.js
									
									
									
									
									
								
							@ -36,8 +36,8 @@ const wo = (global.wo = {
 | 
				
			|||||||
          'Destination path to deploy on the target.'
 | 
					          'Destination path to deploy on the target.'
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
        [
 | 
					        [
 | 
				
			||||||
          'targetDir',
 | 
					          'targetFolder',
 | 
				
			||||||
          '-D, --targetDir <targetDir>',
 | 
					          '-D, --targetFolder <targetFolder>',
 | 
				
			||||||
          'Destination folder to deploy on the target.'
 | 
					          'Destination folder to deploy on the target.'
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -68,7 +68,7 @@ const wo = (global.wo = {
 | 
				
			|||||||
          host: undefined,
 | 
					          host: undefined,
 | 
				
			||||||
          port: 22,
 | 
					          port: 22,
 | 
				
			||||||
          targetPath: undefined, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上
 | 
					          targetPath: undefined, // 目标服务器上的目录。似乎该目录必须已经存在于服务器上
 | 
				
			||||||
          targetDir: '_webroot', // 新系统将发布在这个文件夹里。建议为dist,和npm run build产生的目录一致,这样既可以远程自动部署,也可以直接登录服务器手动部署。
 | 
					          targetFolder: '_webroot', // 新系统将发布在这个文件夹里。建议为dist,和npm run build产生的目录一致,这样既可以远程自动部署,也可以直接登录服务器手动部署。
 | 
				
			||||||
          user: undefined,
 | 
					          user: undefined,
 | 
				
			||||||
          password: undefined,
 | 
					          password: undefined,
 | 
				
			||||||
          privateKey: `${process.env.HOME}/.ssh/id_rsa`
 | 
					          privateKey: `${process.env.HOME}/.ssh/id_rsa`
 | 
				
			||||||
@ -152,36 +152,38 @@ function deployToSsh (connection) {
 | 
				
			|||||||
    .connect(connection)
 | 
					    .connect(connection)
 | 
				
			||||||
    .then(async () => {
 | 
					    .then(async () => {
 | 
				
			||||||
      console.log(
 | 
					      console.log(
 | 
				
			||||||
        `[ mv ${connection.targetDir} ${
 | 
					        `[ mv ${connection.targetFolder} ${
 | 
				
			||||||
          connection.targetDir
 | 
					          connection.targetFolder
 | 
				
			||||||
        }-backup-${new Date().toISOString()} ... ]`
 | 
					        }-backup-${new Date().toISOString()} ... ]`
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      await ssh.execCommand(
 | 
					      await ssh.execCommand(
 | 
				
			||||||
        `mv ${connection.targetDir} ${
 | 
					        `mv ${connection.targetFolder} ${
 | 
				
			||||||
          connection.targetDir
 | 
					          connection.targetFolder
 | 
				
			||||||
        }-backup-${new Date().toISOString()}`,
 | 
					        }-backup-${new Date().toISOString()}`,
 | 
				
			||||||
        { cwd: connection.targetPath }
 | 
					        { cwd: connection.targetPath }
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      console.log(`[ mkdir ${connection.targetDir} ... ]`)
 | 
					      console.log(`[ mkdir ${connection.targetFolder} ... ]`)
 | 
				
			||||||
      await ssh.execCommand(`mkdir ${connection.targetDir}`, {
 | 
					      await ssh.execCommand(`mkdir ${connection.targetFolder}`, {
 | 
				
			||||||
        cwd: connection.targetPath
 | 
					        cwd: connection.targetPath
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
      const toCreate = necessaryPath(path.join('./', envarDeploy.fromPath))
 | 
					      const toCreate = necessaryPath(path.join('./', envarDeploy.fromPath))
 | 
				
			||||||
      for (const name of toCreate) {
 | 
					      for (const name of toCreate) {
 | 
				
			||||||
        console.log(`[ mkdir ${connection.targetDir}/${name.join('/')} ... ]`)
 | 
					        console.log(
 | 
				
			||||||
 | 
					          `[ mkdir ${connection.targetFolder}/${name.join('/')} ... ]`
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        await ssh.execCommand(
 | 
					        await ssh.execCommand(
 | 
				
			||||||
          `mkdir ${connection.targetDir}/${name.join('/')}`,
 | 
					          `mkdir ${connection.targetFolder}/${name.join('/')}`,
 | 
				
			||||||
          { cwd: connection.targetPath }
 | 
					          { cwd: connection.targetPath }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      let err
 | 
					      let err
 | 
				
			||||||
      console.log(
 | 
					      console.log(
 | 
				
			||||||
        `[ Upload to ${connection.targetPath}/${connection.targetDir} ... ]`
 | 
					        `[ Upload to ${connection.targetPath}/${connection.targetFolder} ... ]`
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      await ssh.putDirectory(
 | 
					      await ssh.putDirectory(
 | 
				
			||||||
        path.join('./', envarDeploy.fromPath),
 | 
					        path.join('./', envarDeploy.fromPath),
 | 
				
			||||||
        `${connection.targetPath}/${connection.targetDir}`,
 | 
					        `${connection.targetPath}/${connection.targetFolder}`,
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          concurrency: 10,
 | 
					          concurrency: 10,
 | 
				
			||||||
          recursive: true,
 | 
					          recursive: true,
 | 
				
			||||||
@ -191,8 +193,9 @@ function deployToSsh (connection) {
 | 
				
			|||||||
          },
 | 
					          },
 | 
				
			||||||
          tick: (fromPath, remotePath, error) => {
 | 
					          tick: (fromPath, remotePath, error) => {
 | 
				
			||||||
            console.log(
 | 
					            console.log(
 | 
				
			||||||
              `Uploading "${fromPath}" ===> "${remotePath}" ${error ||
 | 
					              `Uploading "${fromPath}" ===> "${remotePath}" ${
 | 
				
			||||||
                'succeeded!'}`
 | 
					                error || 'succeeded!'
 | 
				
			||||||
 | 
					              }`
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
            err = error
 | 
					            err = error
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -201,12 +204,12 @@ function deployToSsh (connection) {
 | 
				
			|||||||
      ssh.dispose()
 | 
					      ssh.dispose()
 | 
				
			||||||
      if (err) {
 | 
					      if (err) {
 | 
				
			||||||
        console.error(
 | 
					        console.error(
 | 
				
			||||||
          `🤷♀️🤷♀️🤷♀️ Failed deploy ${envarDeploy.fromPath} to ${connection.targetPath}/${connection.targetDir} 🤷♀️🤷♀️🤷♀️`
 | 
					          `🤷♀️🤷♀️🤷♀️ Failed deploy ${envarDeploy.fromPath} to ${connection.targetPath}/${connection.targetFolder} 🤷♀️🤷♀️🤷♀️`
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        process.exit(1)
 | 
					        process.exit(1)
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        console.info(
 | 
					        console.info(
 | 
				
			||||||
          `😊😊😊 Successfully deployed [${envarDeploy.fromPath}] to [${connection.targetPath}/${connection.targetDir}] 😊😊😊`
 | 
					          `😊😊😊 Successfully deployed [${envarDeploy.fromPath}] to [${connection.targetPath}/${connection.targetFolder}] 😊😊😊`
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        if (connection.url) {
 | 
					        if (connection.url) {
 | 
				
			||||||
          console.info(`😊😊😊 ${connection.url} 😊😊😊`)
 | 
					          console.info(`😊😊😊 ${connection.url} 😊😊😊`)
 | 
				
			||||||
@ -218,7 +221,7 @@ function deployToSsh (connection) {
 | 
				
			|||||||
      console.error(err)
 | 
					      console.error(err)
 | 
				
			||||||
      ssh.dispose()
 | 
					      ssh.dispose()
 | 
				
			||||||
      console.error(
 | 
					      console.error(
 | 
				
			||||||
        `🤷♀️🤷♀️🤷♀️ Failed deploy [${envarDeploy.fromPath}] to [${connection.targetPath}/${connection.targetDir}] 🤷♀️🤷♀️🤷♀️`
 | 
					        `🤷♀️🤷♀️🤷♀️ Failed deploy [${envarDeploy.fromPath}] to [${connection.targetPath}/${connection.targetFolder}] 🤷♀️🤷♀️🤷♀️`
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      process.exit(1)
 | 
					      process.exit(1)
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
@ -240,7 +243,8 @@ function deployToGit (connection) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const rRepoURL = /^(?:(?:git|https?|git\+https|git\+ssh):\/\/)?(?:[^@]+@)?([^\/]+?)[\/:](.+?)\.git$/ // eslint-disable-line no-useless-escape
 | 
					  const rRepoURL =
 | 
				
			||||||
 | 
					    /^(?:(?:git|https?|git\+https|git\+ssh):\/\/)?(?:[^@]+@)?([^\/]+?)[\/:](.+?)\.git$/ // eslint-disable-line no-useless-escape
 | 
				
			||||||
  const rGithubPage = /\.github\.(io|com)$/
 | 
					  const rGithubPage = /\.github\.(io|com)$/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function parseRepo (repo) {
 | 
					  function parseRepo (repo) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user