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 { indent } = require('./indent-bullet')
|
7 | const indent2 = indent.bind(null, 2)
|
8 |
|
9 | const chownComp = `sudo chown -R \`whoami\` ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/HTML5Components/blink-components-release`
|
10 | const lsComp = `ls -ld ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/HTML5Components/blink-components-release`
|
11 | const noComp = `Your Animate CC components folder does not exist`
|
12 | const checkACC = `Ensure your Animate CC is up to date`
|
13 | const getComp = `Download and install components with the following command:
|
14 | ${chalk.italic.gray('blink components')}`
|
15 | const logCompPerm = `Check permissions with the following command:
|
16 | ${chalk.italic.gray(lsComp)}`
|
17 | const compPermFix = `If the user shows as 'root' and/or not your username, try the following:
|
18 | ${chalk.italic.gray(chownComp)}
|
19 | The permissions should match "drwxrwxrwx"`
|
20 | const compPermissions = 'Check permissions for the blink components directory'
|
21 | const permFormat = `Output should resemble the following:
|
22 | [permissions] [links] [user] ...`
|
23 | const noCompJson = `Cannot locate or access the version of blink components`
|
24 | const oldComp = `You are using an older version of blink components`
|
25 | const configurationAcc = require('../AnimtePaths/getConfigurationPath')
|
26 | const getCompPath = require('../AnimtePaths/getBlinkComponentReleases')
|
27 | module.exports = async ({ env, pkg }) => {
|
28 | let warnings = []
|
29 | let details = []
|
30 | let accConfigPath = []
|
31 | accConfigPath = configurationAcc()
|
32 | let componentPath = ''
|
33 | if (accConfigPath.length > 0) {
|
34 | for (var i = 0; i < accConfigPath.length; i++) {
|
35 | if (accConfigPath[i].toString().includes('2020')) {
|
36 | componentPath = getCompPath(accConfigPath[i])
|
37 | console.log(componentPath)
|
38 | }
|
39 | }
|
40 | }
|
41 | try {
|
42 | await fs.access(componentPath, fs.constants.R_OK | fs.constants.W_OK)
|
43 | try {
|
44 | const data = await fs.readJson(path.join(componentPath, 'package.json'), fsOpts)
|
45 | if (upToDate(data.version, pkg.blinkComponentsVersion.slice(1))) {
|
46 | details.push(chalk`You are using blink components version ${data.version} {green (up to date)}`)
|
47 | } else {
|
48 | details.push(chalk`You are using blink components version ${data.version} {red (not up to date)}`)
|
49 | warnings.push(`${oldComp}\n${indent2(getComp)}`)
|
50 | }
|
51 | } catch (err) {
|
52 | warnings.push(`${noCompJson}\n${indent2(getComp)}`)
|
53 | }
|
54 | } catch (err) {
|
55 | if (err.code === 'ENOENT') warnings.push(`${noComp}\n${indent2(checkACC)}\n${indent2(getComp)}\n${indent2(logCompPerm)}`)
|
56 | else if (err.code === 'EACCES') warnings.push(`${compPermissions}\n${indent2(`${logCompPerm}\n${permFormat}\n${compPermFix}`)}`)
|
57 | else warnings.push(`${compPermissions}\n${indent2(logCompPerm)}`)
|
58 | }
|
59 | return { warnings, details }
|
60 | }
|