UNPKG

3.1 kBJavaScriptView Raw
1const chalk = require('chalk')
2const path = require('path')
3const fs = require('fs-extra')
4const upToDate = require('./up-to-date')
5const { indent } = require('./indent-bullet')
6const indent2 = indent.bind(null, 2)
7const getSnippetVersion = require('../snippets/get-version')
8
9const chownSnip = `sudo chown -R \`whoami\` ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/CodeSnippets`
10const lsSnip = `ls -ld ~/Library/"Application Support"/Adobe/"Animate 2020"/en_US/Configuration/CodeSnippets`
11const noSnip = `Your Animate CC snippets folder does not exist`
12const checkACC = `Ensure your Animate CC is up to date`
13const getSnip = `Download and install snippets with the following command:
14 ${chalk.italic.gray('blink snippets')}`
15const logSnipPerm = `Check permissions with the following command:
16 ${chalk.italic.gray(lsSnip)}`
17const snipPermFix = `If the user shows as 'root' and/or not your username, try the following:
18 ${chalk.italic.gray(chownSnip)}
19The permissions should match "drwxrwxrwx"`
20const snipPermissions = 'Check permissions for the blink snippets directory'
21const permFormat = `Output should resemble the following:
22[permissions] [links] [user] ...`
23const noSnipJson = `Cannot locate or access the version of blink snippets`
24const oldSnip = `You are using an older version of blink snippets`
25const configurationAcc = require('../AnimtePaths/getConfigurationPath')
26const getSnippetPath = require('../AnimtePaths/getBlinkCodeSinppets')
27module.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}