Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Zcli package ignore" #144

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

This file was deleted.

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: 'admin@z3ntest.com',
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.