@sequencemedia/gulp-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ import ansi from './ansi.mjs'
2
+ import tildify from './tildify.mjs'
3
+
4
+ import logTasks from './log/tasks.mjs'
5
+ import getTask from './get-task.mjs'
6
+
7
+ export default function runGulpTasksTree (gulp, cliProps, envProps, configProps) {
8
+ const tree = gulp.tree({ deep: true })
9
+ if (configProps.description && typeof configProps.description === 'string') {
10
+ tree.label = configProps.description
11
+ } else {
12
+ tree.label = `Tasks for ${ansi.magenta(tildify(envProps.configPath))}`
13
+ }
14
+
15
+ return logTasks(tree, cliProps, getTask(gulp))
16
+ }
@@ -0,0 +1,46 @@
1
+ import log from 'gulplog'
2
+
3
+ import ansi from './ansi.mjs'
4
+ import exit from './exit.mjs'
5
+ import tildify from './tildify.mjs'
6
+
7
+ import runGulpTasksListTree from './run-gulp-tasks-list-tree.mjs'
8
+ import runGulpTasksTree from './run-gulp-tasks-tree.mjs'
9
+ import runGulpTasksJsonTree from './run-gulp-tasks-json-tree.mjs'
10
+
11
+ function getMethodFromCliProps ({ series = false }) {
12
+ return series ? 'series' : 'parallel'
13
+ }
14
+
15
+ function getTasksFromCliProps ({ _: tasks = [] }) {
16
+ return (
17
+ tasks.length ? [...tasks] : ['default']
18
+ )
19
+ }
20
+
21
+ export default function runGulpTasks (gulp, cliProps, envProps, configProps) {
22
+ if (cliProps.tasksList) return runGulpTasksListTree(gulp)
23
+
24
+ if (cliProps.tasks) return runGulpTasksTree(gulp, cliProps, envProps, configProps)
25
+
26
+ if (cliProps.tasksJson) return runGulpTasksJsonTree(gulp, cliProps, envProps, configProps)
27
+
28
+ try {
29
+ const {
30
+ configPath
31
+ } = envProps
32
+
33
+ log.info(`Using gulpfile ${ansi.magenta(tildify(configPath))}`)
34
+
35
+ const method = getMethodFromCliProps(cliProps)
36
+ const tasks = getTasksFromCliProps(cliProps)
37
+
38
+ return (
39
+ gulp[method](tasks)((e) => e && exit(1))
40
+ )
41
+ } catch ({ message }) {
42
+ log.error(ansi.red(message))
43
+ log.error('To list available tasks run: gulp --tasks')
44
+ exit(1)
45
+ }
46
+ }
@@ -0,0 +1,56 @@
1
+ import path from 'node:path'
2
+
3
+ import {
4
+ readFile
5
+ } from 'node:fs/promises'
6
+
7
+ import log from 'gulplog'
8
+
9
+ import ansi from './ansi.mjs'
10
+ import exit from './exit.mjs'
11
+ import tildify from './tildify.mjs'
12
+
13
+ import getBlacklist from './get-blacklist.mjs'
14
+ import getPackageBlacklist from './get-package-blacklist.mjs'
15
+
16
+ function getPackagePath (envProps, cliProps) {
17
+ let packagePath = cliProps.verify !== true ? cliProps.verify : './package.json'
18
+
19
+ if (path.resolve(packagePath) !== path.normalize(packagePath)) {
20
+ packagePath = path.join(path.normalize(envProps.cwd), packagePath)
21
+ }
22
+
23
+ return packagePath
24
+ }
25
+
26
+ async function getPackageJson (packagePath) {
27
+ const fileData = await readFile(packagePath)
28
+ return JSON.parse(fileData.toString())
29
+ }
30
+
31
+ export default async function runVerify (envProps, cliProps) {
32
+ const packagePath = getPackagePath(envProps, cliProps)
33
+
34
+ log.info(`Verifying dependencies in ${ansi.magenta(tildify(packagePath))}`)
35
+ try {
36
+ const blacklistJson = await getBlacklist()
37
+ const packageJson = await getPackageJson(packagePath)
38
+ const packageBlacklist = getPackageBlacklist(packageJson, blacklistJson)
39
+
40
+ const dependencies = Object.entries(packageBlacklist)
41
+ if (dependencies.length) {
42
+ log.warn(ansi.red('Blacklisted dependencies in this project:'))
43
+ dependencies
44
+ .forEach(([name, reason]) => {
45
+ log.warn(`${ansi.bgred(name)}: ${reason}`)
46
+ })
47
+ exit(1)
48
+ }
49
+
50
+ log.info(ansi.green('There are no blacklisted dependencies in this project'))
51
+ exit(0)
52
+ } catch ({ message }) {
53
+ log.error(`${ansi.red('Failed to verify dependencies.')} Could not get blacklist - ${message}`)
54
+ exit(1)
55
+ }
56
+ }
@@ -0,0 +1,26 @@
1
+ import {
2
+ join
3
+ } from 'node:path'
4
+
5
+ import exit from './exit.mjs'
6
+
7
+ import ROOT from '#where-am-i'
8
+
9
+ async function getGulpCliVersion () {
10
+ const {
11
+ default: {
12
+ version
13
+ }
14
+ } = await import(join(ROOT, 'package.json'), { assert: { type: 'json' } })
15
+ return version
16
+ }
17
+
18
+ function getGulpVersion ({ modulePackage: { version = 'unknown' } = {} }) {
19
+ return version
20
+ }
21
+
22
+ export default async function runVersion (envProps) {
23
+ console.log(`Gulp CLI version: ${await getGulpCliVersion()}`)
24
+ console.log(`Gulp version: ${getGulpVersion(envProps)}`)
25
+ exit(0)
26
+ }
@@ -0,0 +1,5 @@
1
+ import replaceHomedir from 'replace-homedir'
2
+
3
+ export default function tildify (filePath) {
4
+ return replaceHomedir(filePath, '~')
5
+ }
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@sequencemedia/gulp-cli",
3
+ "version": "1.0.0",
4
+ "description": "Command line interface for gulp",
5
+ "keywords": [
6
+ "build",
7
+ "stream",
8
+ "system",
9
+ "make",
10
+ "tool",
11
+ "asset",
12
+ "pipeline"
13
+ ],
14
+ "main": "./index.mjs",
15
+ "type": "module",
16
+ "author": "Jonathan Perry for Sequence Media Limited <sequencemedia@sequencemedia.net>",
17
+ "contributors": [
18
+ "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)"
19
+ ],
20
+ "license": "MIT",
21
+ "engines": {
22
+ "node": ">=18.5.0"
23
+ },
24
+ "repository": "sequencemedia/gulp-cli",
25
+ "homepage": "https://gulpjs.com",
26
+ "scripts": {
27
+ "lint": "eslint . --ext .mjs --ext .cjs",
28
+ "lint:fix": "npm run lint -- --fix",
29
+ "test": "NODE_OPTIONS=--no-warnings mocha -b --recursive test/gulp-cli",
30
+ "prepare": "husky install"
31
+ },
32
+ "bin": {
33
+ "gulp": "bin/gulp.mjs"
34
+ },
35
+ "dependencies": {
36
+ "@sequencemedia/liftoff": "1.0.0",
37
+ "ansi-colors": "^4.1.3",
38
+ "archy": "^1.0.0",
39
+ "array-sort": "^1.0.0",
40
+ "color-support": "^1.1.3",
41
+ "copy-props": "^4.0.0",
42
+ "fancy-log": "^2.0.0",
43
+ "gulplog": "^2.0.1",
44
+ "interpret": "^3.1.1",
45
+ "isobject": "^4.0.0",
46
+ "matchdep": "^2.0.0",
47
+ "mute-stdout": "^2.0.0",
48
+ "pretty-hrtime": "^1.0.3",
49
+ "replace-homedir": "^2.0.0",
50
+ "v8flags": "^4.0.0",
51
+ "yargs": "^17.7.2"
52
+ },
53
+ "devDependencies": {
54
+ "@babel/core": "^7.21.5",
55
+ "@babel/eslint-parser": "^7.21.3",
56
+ "@babel/plugin-syntax-import-assertions": "^7.20.0",
57
+ "@babel/preset-env": "^7.21.5",
58
+ "chai": "^4.3.7",
59
+ "eslint": "^8.39.0",
60
+ "eslint-config-standard": "^17.0.0",
61
+ "eslint-plugin-import": "^2.27.5",
62
+ "eslint-plugin-node": "^11.1.0",
63
+ "eslint-plugin-promise": "^6.1.1",
64
+ "expect": "^29.5.0",
65
+ "husky": "^8.0.3",
66
+ "mocha": "^10.2.0",
67
+ "rimraf": "^5.0.0",
68
+ "sinon": "^15.0.4"
69
+ },
70
+ "man": "gulp.1",
71
+ "files": [
72
+ "index.mjs",
73
+ "where-am-i.mjs",
74
+ "lib",
75
+ "bin",
76
+ "completion",
77
+ "gulp.1"
78
+ ],
79
+ "imports": {
80
+ "#gulp-cli/lib/*": "./lib/*.mjs",
81
+ "#gulp-cli": "./index.mjs",
82
+ "#where-am-i": "./where-am-i.mjs"
83
+ }
84
+ }
package/where-am-i.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import {
2
+ fileURLToPath
3
+ } from 'node:url'
4
+
5
+ import {
6
+ dirname
7
+ } from 'node:path'
8
+
9
+ export default dirname(fileURLToPath(import.meta.url))