UNPKG

2.96 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 { indent } = require('./indent-bullet')
7const indent2 = indent.bind(null, 2)
8
9const chownComp = `sudo chown -R \`whoami\` ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/HTML5Components/blink-components-release`
10const lsComp = `ls -ld ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/HTML5Components/blink-components-release`
11const noComp = `Your Animate CC components folder does not exist`
12const checkACC = `Ensure your Animate CC is up to date`
13const getComp = `Download and install components with the following command:
14 ${chalk.italic.gray('blink components')}`
15const logCompPerm = `Check permissions with the following command:
16 ${chalk.italic.gray(lsComp)}`
17const compPermFix = `If the user shows as 'root' and/or not your username, try the following:
18 ${chalk.italic.gray(chownComp)}
19The permissions should match "drwxrwxrwx"`
20const compPermissions = 'Check permissions for the blink components directory'
21const permFormat = `Output should resemble the following:
22[permissions] [links] [user] ...`
23const noCompJson = `Cannot locate or access the version of blink components`
24const oldComp = `You are using an older version of blink components`
25const configurationAcc = require('../AnimtePaths/getConfigurationPath')
26const getCompPath = require('../AnimtePaths/getBlinkComponentReleases')
27module.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}