1 | const chalk = require('chalk')
|
2 | const path = require('path')
|
3 | const fs = require('fs-extra')
|
4 | const upToDate = require('./up-to-date')
|
5 | const { indent } = require('./indent-bullet')
|
6 | const indent2 = indent.bind(null, 2)
|
7 | const getSnippetVersion = require('../snippets/get-version')
|
8 |
|
9 | const chownSnip = `sudo chown -R \`whoami\` ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/CodeSnippets`
|
10 | const lsSnip = `ls -ld ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/CodeSnippets`
|
11 | const noSnip = `Your Animate CC snippets folder does not exist`
|
12 | const checkACC = `Ensure your Animate CC is up to date`
|
13 | const getSnip = `Download and install snippets with the following command:
|
14 | ${chalk.italic.gray('blink snippets')}`
|
15 | const logSnipPerm = `Check permissions with the following command:
|
16 | ${chalk.italic.gray(lsSnip)}`
|
17 | const snipPermFix = `If the user shows as 'root' and/or not your username, try the following:
|
18 | ${chalk.italic.gray(chownSnip)}
|
19 | The permissions should match "drwxrwxrwx"`
|
20 | const snipPermissions = 'Check permissions for the blink snippets directory'
|
21 | const permFormat = `Output should resemble the following:
|
22 | [permissions] [links] [user] ...`
|
23 | const noSnipJson = `Cannot locate or access the version of blink snippets`
|
24 | const oldSnip = `You are using an older version of blink snippets`
|
25 | const configurationAcc = require('../AnimtePaths/getConfigurationPath')
|
26 | const getSnippetPath = require('../AnimtePaths/getBlinkCodeSinppets')
|
27 | module.exports = async ({ env, pkg }) => {
|
28 | let warnings = []
|
29 | let details = []
|
30 | let accConfigPath = []
|
31 | accConfigPath = configurationAcc()
|
32 | let snippetPath = ''
|
33 | if (accConfigPath.length > 0) {
|
34 | for (var i = 0; i < accConfigPath.length; i++) {
|
35 | if (accConfigPath[i].toString().includes('2020')) {
|
36 | snippetPath = getSnippetPath(accConfigPath[i])
|
37 | }
|
38 | }
|
39 | }
|
40 | try {
|
41 | await fs.access(snippetPath, fs.constants.R_OK | fs.constants.W_OK)
|
42 | try {
|
43 | console.log(snippetPath)
|
44 | let snippetVersion = await getSnippetVersion(path.join(snippetPath, 'CodeSnippets.xml'))
|
45 | if (/DEV$/.test(snippetVersion)) {
|
46 | details.push(chalk`You are using blink snippets dev version ${snippetVersion} {yellow (prod is ${pkg.blinkSnippetsVersion})}`)
|
47 | } else if (upToDate(snippetVersion.slice(1), pkg.blinkSnippetsVersion.slice(1))) {
|
48 | details.push(chalk`You are using blink snippets version ${snippetVersion} {green (up to date)}`)
|
49 | } else {
|
50 | details.push(chalk`You are using blink snippets version ${snippetVersion} {red (not up to date)}`)
|
51 | warnings.push(`${oldSnip}\n${indent2(getSnip)}`)
|
52 | }
|
53 | } catch (err) {
|
54 | warnings.push(`${noSnipJson}\n${indent2(getSnip)}`)
|
55 | }
|
56 | } catch (err) {
|
57 | if (err.code === 'ENOENT') warnings.push(`${noSnip}\n${indent2(checkACC)}\n${indent2(getSnip)}\n${indent2(logSnipPerm)}`)
|
58 | else if (err.code === 'EACCES') warnings.push(`${snipPermissions}\n${indent2(`${logSnipPerm}\n${permFormat}\n${snipPermFix}`)}`)
|
59 | else warnings.push(`${snipPermissions}\n${indent2(logSnipPerm)}`)
|
60 | }
|
61 | return { warnings, details }
|
62 | }
|