@zendesk/zcli-apps
Advanced tools
Comparing version 1.0.0-beta.8 to 1.0.0-beta.9
@@ -6,2 +6,10 @@ # Change Log | ||
# 1.0.0-beta.9 (2021-11-04) | ||
**Note:** Version bump only for package @zendesk/zcli-apps | ||
# [1.0.0-beta.8](https://github.com/zendesk/zcli/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2021-03-13) | ||
@@ -8,0 +16,0 @@ |
@@ -13,7 +13,8 @@ import { Command, flags } from '@oclif/command'; | ||
zipScaffoldPath: string; | ||
unzippedScaffoldPath: string; | ||
EMAIL_REGEX: RegExp; | ||
downloadScaffold(url: string): Promise<unknown>; | ||
getScaffoldDir(flagScaffold: string): string; | ||
downloadScaffoldsRepo(url: string): Promise<unknown>; | ||
extractScaffoldIfExists(flagScaffold: string, directoryName: string): Promise<unknown>; | ||
modifyManifest(directoryName: string, appName: string, authorName: string, authorEmail: string, flagScaffold: string): void; | ||
run(): Promise<void>; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
const fs = require("fs"); | ||
const fsExtra = require("fs-extra"); | ||
const https = require("https"); | ||
@@ -18,5 +19,6 @@ const path = require("path"); | ||
this.zipScaffoldPath = path.join(process.cwd(), 'scaffold.zip'); | ||
this.unzippedScaffoldPath = path.join(process.cwd(), 'app_scaffolds-master'); | ||
this.EMAIL_REGEX = /^.+@.+\..+$/; | ||
} | ||
async downloadScaffold(url) { | ||
async downloadScaffoldsRepo(url) { | ||
return new Promise((resolve, reject) => { | ||
@@ -30,6 +32,8 @@ const destination = fs.createWriteStream(this.zipScaffoldPath); | ||
const overwrite = false; | ||
zip.extractAllToAsync(path.join(process.cwd()), overwrite, (err) => { | ||
zip.extractAllToAsync(path.join(process.cwd()), overwrite, async (err) => { | ||
await fileUtils_1.cleanDirectory(this.zipScaffoldPath); | ||
if (err) { | ||
reject(err); | ||
} | ||
// @ts-ignore | ||
resolve(); | ||
@@ -40,12 +44,18 @@ }); | ||
} | ||
getScaffoldDir(flagScaffold) { | ||
const scaffolds = { | ||
basic: 'apps_scaffold_basic', | ||
react: 'app_scaffold' | ||
}; | ||
const scaffoldRepo = scaffolds[flagScaffold]; | ||
if (!scaffoldRepo) { | ||
throw new errors_1.CLIError(chalk.red(`Invalid scaffold option entered ${flagScaffold}`)); | ||
} | ||
return scaffoldRepo; | ||
async extractScaffoldIfExists(flagScaffold, directoryName) { | ||
return new Promise((resolve, reject) => { | ||
fsExtra.copy(path.join(process.cwd(), '/', 'app_scaffolds-master/packages/', flagScaffold), path.join(process.cwd(), directoryName), | ||
// @ts-ignore | ||
{ overwrite: true, errorOnExist: true }, async (err) => { | ||
await fileUtils_1.cleanDirectory(this.unzippedScaffoldPath); | ||
if (err) { | ||
if (err.code === 'ENOENT') { | ||
reject(new Error(`Scaffold ${flagScaffold} does not exist: ${err}`)); | ||
} | ||
reject(err); | ||
} | ||
// @ts-ignore | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
@@ -74,19 +84,11 @@ modifyManifest(directoryName, appName, authorName, authorEmail, flagScaffold) { | ||
const appName = flags.appName || await cli_ux_1.default.prompt('Enter a name for this new app'); | ||
const scaffoldRepo = this.getScaffoldDir(flagScaffold); | ||
const scaffoldDir = scaffoldRepo + '-master'; | ||
const scaffoldUrl = `https://codeload.github.com/zendesk/${scaffoldRepo}/zip/master`; | ||
const scaffoldUrl = 'https://codeload.github.com/zendesk/app_scaffolds/zip/master'; | ||
try { | ||
await this.downloadScaffold(scaffoldUrl); | ||
await this.downloadScaffoldsRepo(scaffoldUrl); | ||
await this.extractScaffoldIfExists(flagScaffold, directoryName); | ||
} | ||
catch (err) { | ||
throw new errors_1.CLIError(chalk.red('Download of scaffold structure failed')); | ||
throw new errors_1.CLIError(chalk.red(`Download of scaffold structure failed with error: ${err}`)); | ||
} | ||
fs.renameSync(path.join(process.cwd(), scaffoldDir), path.join(process.cwd(), directoryName)); | ||
this.modifyManifest(directoryName, appName, authorName, authorEmail, flagScaffold); | ||
try { | ||
await fileUtils_1.cleanDirectory(this.zipScaffoldPath); | ||
} | ||
catch (err) { | ||
console.log(chalk.yellow(`Failed to clean up ${this.zipScaffoldPath}`)); | ||
} | ||
console.log(chalk.green(`Successfully created new project ${directoryName}`)); | ||
@@ -93,0 +95,0 @@ } |
@@ -25,2 +25,5 @@ export interface ZcliConfigFileContent { | ||
} | ||
export interface FsExtraError extends Error { | ||
code: string; | ||
} | ||
export interface Manifest { | ||
@@ -27,0 +30,0 @@ name?: string; |
{ | ||
"name": "@zendesk/zcli-apps", | ||
"description": "zcli apps commands live here", | ||
"version": "1.0.0-beta.8", | ||
"version": "1.0.0-beta.9", | ||
"author": "@vegemite", | ||
@@ -21,10 +21,10 @@ "npmRegistry": "https://registry.npmjs.org", | ||
"@oclif/config": "^1", | ||
"adm-zip": "0.5.1", | ||
"adm-zip": "0.5.5", | ||
"archiver": "4.0.2", | ||
"chalk": "4.1.0", | ||
"chalk": "4.1.2", | ||
"cli-ux": "^5.4.1", | ||
"cors": "^2.8.5", | ||
"express": "^4.17.1", | ||
"form-data": "3.0.0", | ||
"fs-extra": "9.0.1", | ||
"form-data": "3.0.1", | ||
"fs-extra": "^10.0.0", | ||
"morgan": "1.10.0", | ||
@@ -78,3 +78,3 @@ "node-fetch": "^2.6.0", | ||
"types": "lib/index.d.ts", | ||
"gitHead": "f71ee83b36cbf4899dab090bbf122a679c39aaf7" | ||
"gitHead": "8e71edc69d3cb85020bffe26f9f9c2e77c9ce6a6" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
77022
1626
16
2
+ Addedadm-zip@0.5.5(transitive)
+ Addedform-data@3.0.1(transitive)
+ Addedfs-extra@10.1.0(transitive)
- Removedadm-zip@0.5.1(transitive)
- Removedat-least-node@1.0.0(transitive)
- Removedchalk@4.1.0(transitive)
- Removedform-data@3.0.0(transitive)
- Removedfs-extra@9.0.1(transitive)
- Removeduniversalify@1.0.0(transitive)
Updatedadm-zip@0.5.5
Updatedchalk@4.1.2
Updatedform-data@3.0.1
Updatedfs-extra@^10.0.0