Comparing version 2.0.0-beta.3 to 2.0.0-beta.4
{ | ||
"name": "netlify", | ||
"description": "Netlify Node.js API client", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.4", | ||
"author": "Netlify Inc.", | ||
@@ -6,0 +6,0 @@ "ava": { |
@@ -131,2 +131,3 @@ # netlify/js-client | ||
**Node.js Only**: Pass in a `siteId`, a `buildDir` (the folder you want to deploy) and an options object to deploy the contents of that folder. | ||
Sometimes need to write to a `tmpDir`. | ||
@@ -149,2 +150,3 @@ The following paths can be passed in the options: | ||
filter: filename => { /* return false to filter a file from the deploy */ } | ||
tmlDir: tempy.directory(), // a temporary directory to zip loose files into | ||
statusCb: statusObj => { | ||
@@ -151,0 +153,0 @@ // a callback function to receive status events |
@@ -6,3 +6,2 @@ const promisifyAll = require('util.promisify-all') | ||
const fromArray = require('from2-array') | ||
const tempy = require('tempy') | ||
@@ -18,3 +17,3 @@ const { hasherCtor, manifestCollectorCtor, fnStatCtor, fnFilterCtor } = require('./hasher-segments') | ||
hashAlgorithm: 'sha256', | ||
tmpDir: tempy.directory(), | ||
// tmpDir, | ||
statusCb: () => {} | ||
@@ -27,2 +26,3 @@ }, | ||
if (!opts.filter) throw new Error('Missing required filter function') | ||
if (!opts.tmpDir) throw new Error('Missing tmpDir directory for zipping files') | ||
@@ -29,0 +29,0 @@ const fileList = await fs.readdir(dir).then(files => files.filter(opts.filter)) |
const test = require('ava') | ||
const hashFns = require('./hash-fns') | ||
const { defaultFilter } = require('./util') | ||
const tempy = require('tempy') | ||
test('hashes files in a folder', async t => { | ||
const { functions, fnShaMap } = await hashFns(__dirname, { filter: defaultFilter }) | ||
const { functions, fnShaMap } = await hashFns(__dirname, { filter: defaultFilter, tmpDir: tempy.directory() }) | ||
@@ -8,0 +9,0 @@ Object.keys(functions).forEach(path => t.truthy(path, 'each file has a path')) |
@@ -5,2 +5,3 @@ const uploadFiles = require('./upload-files') | ||
const cleanDeep = require('clean-deep') | ||
const tempy = require('tempy') | ||
@@ -16,2 +17,3 @@ const { waitForDeploy, getUploadList, defaultFilter } = require('./util') | ||
draft: false, | ||
tmpDir: tempy.directory(), | ||
deployTimeout: 1.2e6, // local deploy timeout: 20 mins | ||
@@ -48,3 +50,5 @@ concurrentHash: 100, // concurrent file hash calls | ||
type: 'hashing', | ||
msg: `Finished hashing ${Object.keys(files).length} files and ${Object.keys(functions).length} functions`, | ||
msg: | ||
`Finished hashing ${Object.keys(files).length} files` + | ||
(fnDir ? ` and ${Object.keys(functions).length} functions` : ''), | ||
phase: 'stop' | ||
@@ -59,3 +63,5 @@ }) | ||
let deploy = await api.createSiteDeploy({ siteId, body: cleanDeep({ files, functions, draft: opts.draft }) }) | ||
const deployBody = cleanDeep({ files, functions, draft: opts.draft }) | ||
let deploy = await api.createSiteDeploy({ siteId, body: deployBody }) | ||
const { id: deployId, required: requiredFiles, required_functions: requiredFns } = deploy | ||
@@ -65,3 +71,5 @@ | ||
type: 'create-deploy', | ||
msg: `CDN requesting ${requiredFiles.length} files and ${requiredFns.length} functions`, | ||
msg: | ||
`CDN requesting ${requiredFiles.length} files` + | ||
(Array.isArray(requiredFns) ? ` and ${requiredFns.length} functions` : ''), | ||
phase: 'stop' | ||
@@ -68,0 +76,0 @@ }) |
@@ -58,3 +58,3 @@ const pMap = require('p-map') | ||
type: 'upload', | ||
msg: `Finished uploading ${uploadList.length} files`, | ||
msg: `Finished uploading ${uploadList.length} assets`, | ||
phase: 'stop' | ||
@@ -61,0 +61,0 @@ }) |
@@ -60,2 +60,3 @@ const path = require('path') | ||
function getUploadList(required, shaMap) { | ||
if (!required || !shaMap) return [] | ||
return flatten(required.map(sha => shaMap[sha])) | ||
@@ -62,0 +63,0 @@ } |
47021
981
175