Skip to content

Commit

Permalink
Revert "Zcli package ignore" (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
etanxing authored Nov 10, 2022
1 parent ead7546 commit 625ca70
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 108 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ yarn-error.log
.vscode
packages/zcli-apps/tests/functional/mocks/*/tmp
packages/**/dist
.DS_Store
25 changes: 8 additions & 17 deletions docs/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@

zcli apps commands helps with managing Zendesk apps workflow.

* [`zcli apps:bump [APPPATH]`](#zcli-appsbump-apppath)
* [`zcli apps:clean [APPPATH]`](#zcli-appsclean-apppath)
* [`zcli apps:create APPDIRECTORIES`](#zcli-appscreate-appdirectories)
* [`zcli apps:new`](#zcli-appsnew)
* [`zcli apps:package APPDIRECTORY`](#zcli-appspackage-appdirectory)
* [`zcli apps:server APPDIRECTORIES`](#zcli-appsserver-appdirectories)
* [`zcli apps:update APPDIRECTORIES`](#zcli-appsupdate-appdirectories)
* [`zcli apps:validate APPDIRECTORY`](#zcli-appsvalidate-appdirectory)

## Configuration

NOTE: You can set your apps config/settings in `zcli.apps.config.json` at the root of your app directory ie

```
Expand All @@ -31,12 +20,14 @@ NOTE: You can set your apps config/settings in `zcli.apps.config.json` at the ro

See [these mock apps](https://github.com/zendesk/zcli/tree/master/packages/zcli-apps/tests/functional/mocks) for more references of `zcli.apps.config.json`.

If you wish to specify files/folders to be ignored as part of the packaging process, create a .zcliignore file in your apps root directory. Patterns following the gitignore specification included in a .zcliignore file will be excluded from packaging when any of the following commands are executed:

* zcli apps:package
* zcli apps:create
* zcli apps:update
* zcli apps:validate
* [`zcli apps:bump [APPPATH]`](#zcli-appsbump-apppath)
* [`zcli apps:clean [APPPATH]`](#zcli-appsclean-apppath)
* [`zcli apps:create APPDIRECTORIES`](#zcli-appscreate-appdirectories)
* [`zcli apps:new`](#zcli-appsnew)
* [`zcli apps:package APPDIRECTORY`](#zcli-appspackage-appdirectory)
* [`zcli apps:server APPDIRECTORIES`](#zcli-appsserver-appdirectories)
* [`zcli apps:update APPDIRECTORIES`](#zcli-appsupdate-appdirectories)
* [`zcli apps:validate APPDIRECTORY`](#zcli-appsvalidate-appdirectory)

## `zcli apps:bump [APPPATH]`

Expand Down
12 changes: 2 additions & 10 deletions packages/zcli-apps/src/lib/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ export const createAppPkg = async (

archive.pipe(output)

let archiveIgnore = ['tmp/**']

if (fs.pathExistsSync(`${appPath}/.zcliignore`)) {
archiveIgnore = archiveIgnore.concat(fs.readFileSync(`${appPath}/.zcliignore`).toString().replace(/\r\n/g, '\n').split('\n').filter((item) => {
return (item.trim().startsWith('#') ? null : item.trim())
}))
}

// ignore tmp dir
archive.glob('**', {
cwd: appPath,
ignore: archiveIgnore
ignore: ['tmp/**']
})

await archive.finalize()

if (!fs.pathExistsSync(pkgPath)) {
Expand Down

This file was deleted.

Binary file not shown.
Empty file.

This file was deleted.

Empty file.
Empty file.

This file was deleted.

This file was deleted.

55 changes: 1 addition & 54 deletions packages/zcli-apps/tests/functional/package.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { expect, test } from '@oclif/test'
import * as path from 'path'
import * as fs from 'fs'
import * as readline from 'readline'
import * as AdmZip from 'adm-zip'

describe('package', function () {
const appPath = path.join(__dirname, 'mocks/single_product_app')
Expand All @@ -19,7 +16,7 @@ describe('package', function () {
})
.stdout()
.command(['apps:package', appPath])
.it('should display success message if package is created', ctx => {
.it('should display success message package is created', ctx => {
const pkgPath = path.join(path.relative(process.cwd(), appPath), 'tmp', 'app')
expect(ctx.stdout).to.contain(`Package created at ${pkgPath}`)
})
Expand All @@ -39,53 +36,3 @@ describe('package', function () {
.catch(err => expect(err.message).to.contain('Error: invalid location'))
.it('should display error message if package fails to create')
})

describe('zcliignore', function () {
const appPath = path.join(__dirname, 'mocks/single_product_ignore')
const tmpPath = path.join(appPath, 'tmp')

const file = readline.createInterface({
input: fs.createReadStream(path.join(appPath, '.zcliignore')),
output: process.stdout,
terminal: false
})

const ignoreArr: string[] = [] // array that holds each line of the .ignore file

file.on('line', (line) => {
ignoreArr.push(line) // add to array dynamically
})

after(async () => {
fs.readdir(tmpPath, (err, files) => {
if (err) throw err

for (const file of files) {
fs.unlink(path.join(tmpPath, file), (err) => {
if (err) throw err
})
}
})
})

test
.env({
ZENDESK_SUBDOMAIN: 'z3ntest',
ZENDESK_EMAIL: '[email protected]',
ZENDESK_PASSWORD: '123456' // the universal password
})
.nock('https://z3ntest.zendesk.com', api => {
api
.post('/api/v2/apps/validate')
.reply(200)
})
.stdout()
.command(['apps:package', appPath])
.it('should not include certain files as specified in .zcliignore', async () => {
const packagePath = path.join(tmpPath, (fs.readdirSync(tmpPath).find(fn => fn.startsWith('app'))) + '')
const zip = new AdmZip(packagePath)
for (const zipEntry of zip.getEntries()) {
expect(ignoreArr.includes(zipEntry.name)).to.eq(false)
}
})
})
Binary file added packages/zcli-core/.DS_Store
Binary file not shown.
Binary file added packages/zcli-core/src/.DS_Store
Binary file not shown.

0 comments on commit 625ca70

Please sign in to comment.