UNPKG

1.67 kBJavaScriptView Raw
1const chalk = require('chalk')
2const path = require('path')
3const fs = require('fs-extra')
4const fsOpts = { encoding: 'utf8' }
5const upToDate = require('./up-to-date')
6const configurationAcc = require('../AnimtePaths/getConfigurationPath')
7const noACC = `Could not locate Animate CC version info`
8const accPermissions = `Something went wrong when accessing the Animate CC version info`
9const oldACC = `You are using an older version of Animate CC`
10
11module.exports = async ({ pkg, env }) => {
12 let warnings = []
13 let details = []
14 let accConfigPath = []
15 accConfigPath = configurationAcc()
16 let pathToAnimate2020 = ''
17 for (var i = 0; i < accConfigPath.length; i++) {
18 if (accConfigPath[i].toString().includes('2020')) {
19 pathToAnimate2020 = accConfigPath[i]
20 }
21 }
22 try {
23 const data = await fs.readFile(path.join(pathToAnimate2020, 'VersionInfo.txt'), fsOpts)
24 if (!data) {
25 warnings.push(accPermissions)
26 } else if (!upToDate(data.replace(/\u0000.*/, ''), pkg.adFormatsMinimumSupported.accBuild)) {
27 warnings.push(`${oldACC}\n Update to the latest supported version ${pkg.adFormatsMinimumSupported.accVersion}, build ${pkg.adFormatsMinimumSupported.accBuild}`)
28 details.push(chalk`You are using Animate build ${data} {red (not up to date)}`)
29 } else {
30 details.push(chalk`You are using Animate build ${data}, version ${pkg.adFormatsMinimumSupported.accVersion} {green (up to date)}`)
31 }
32 } catch (err) {
33 if (err.code === 'ENOENT') warnings.push(`${noACC}\n Ensure ACC Version ${pkg.adFormatsMinimumSupported.accVersion} is installed`)
34 else warnings.push(accPermissions)
35 }
36 return { warnings, details }
37}