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 |
|
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 | const warnings = []
|
13 | const details = []
|
14 | const accConfigPath = `${env.home}/Library/Application Support/Adobe/Animate CC 2018/en_US/Configuration/`
|
15 | try {
|
16 | const data = await fs.readFile(path.join(accConfigPath, 'VersionInfo.txt'), fsOpts)
|
17 | if (!data) {
|
18 | warnings.push(accPermissions)
|
19 | } else if (!upToDate(data.replace(/\u0000.*/, ''), pkg.adFormatsMinimumSupported.accBuild)) {
|
20 | warnings.push(`${oldACC}\n Update to the latest supported version ${pkg.adFormatsMinimumSupported.accVersion}, build ${pkg.adFormatsMinimumSupported.accBuild}`)
|
21 | details.push(chalk`You are using Animate CC build ${data} {red (not up to date)}`)
|
22 | } else {
|
23 | details.push(chalk`You are using Animate CC build ${data}, version ${pkg.adFormatsMinimumSupported.accVersion} {green (up to date)}`)
|
24 | }
|
25 | } catch (err) {
|
26 | if (err.code === 'ENOENT') warnings.push(`${noACC}\n Ensure ACC Version ${pkg.adFormatsMinimumSupported.accVersion} is installed`)
|
27 | else warnings.push(accPermissions)
|
28 | }
|
29 | return { warnings, details }
|
30 | }
|