1 | const chalk = require('chalk')
|
2 | const path = require('path')
|
3 | const fs = require('fs-extra')
|
4 | const fsOpts = { encoding: 'utf8' }
|
5 | const upToDate = require('./up-to-date')
|
6 | const configurationAcc = require('../AnimtePaths/getConfigurationPath')
|
7 | const noACC = `Could not locate Animate CC version info`
|
8 | const accPermissions = `Something went wrong when accessing the Animate CC version info`
|
9 | const oldACC = `You are using an older version of Animate CC`
|
10 |
|
11 | module.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 | }
|