fix: tar not working for branches with slashes

This commit is contained in:
Geoffroy Empain 2020-12-18 17:04:12 +01:00
parent 2e4b2ea4bb
commit 3d21eea234
4 changed files with 31 additions and 10 deletions

27
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@getmeli/cli", "name": "@getmeli/cli",
"version": "1.0.0", "version": "1.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1514,6 +1514,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/uuid": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz",
"integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==",
"dev": true
},
"@types/yargs": { "@types/yargs": {
"version": "15.0.9", "version": "15.0.9",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.9.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.9.tgz",
@ -13002,9 +13008,9 @@
} }
}, },
"semantic-release-license": { "semantic-release-license": {
"version": "1.0.0", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/semantic-release-license/-/semantic-release-license-1.0.0.tgz", "resolved": "https://registry.npmjs.org/semantic-release-license/-/semantic-release-license-1.0.2.tgz",
"integrity": "sha512-aRnLnTjsrP67kmKVF0h7lEQi9n3yGXADcuL3iyPajF8gHbzPrYu9iBT9WfzG6pIIqOtx1Clfnx/GSc6CdT/Ypw==", "integrity": "sha512-qZJfGD7L3IDdMDaYJBaxgllnHQxOya+WMMdYIWnOx7ZP2MB4O2N/TXJjmLq7UXmvDSDhcJnUS2Pv1jfDzHwBqA==",
"dev": true "dev": true
}, },
"semver": { "semver": {
@ -13323,6 +13329,11 @@
} }
} }
}, },
"slugify": {
"version": "1.4.6",
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.4.6.tgz",
"integrity": "sha512-ZdJIgv9gdrYwhXqxsH9pv7nXxjUEyQ6nqhngRxoAAOlmMGA28FDq5O4/5US4G2/Nod7d1ovNcgURQJ7kHq50KQ=="
},
"snapdragon": { "snapdragon": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
@ -14582,11 +14593,9 @@
"dev": true "dev": true
}, },
"uuid": { "uuid": {
"version": "8.3.1", "version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==", "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
"dev": true,
"optional": true
}, },
"v8-compile-cache": { "v8-compile-cache": {
"version": "2.2.0", "version": "2.2.0",

View File

@ -28,8 +28,10 @@
"chalk": "^4.1.0", "chalk": "^4.1.0",
"debug": "^4.2.0", "debug": "^4.2.0",
"form-data": "^3.0.0", "form-data": "^3.0.0",
"slugify": "^1.4.6",
"source-map-support": "^0.5.19", "source-map-support": "^0.5.19",
"tar": "^6.0.5", "tar": "^6.0.5",
"uuid": "^8.3.2",
"winston": "^3.3.3", "winston": "^3.3.3",
"yargs": "^15.4.1" "yargs": "^15.4.1"
}, },
@ -41,6 +43,7 @@
"@types/jest": "^25.2.3", "@types/jest": "^25.2.3",
"@types/node": "^12.19.4", "@types/node": "^12.19.4",
"@types/tar": "^4.0.3", "@types/tar": "^4.0.3",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^3.9.0", "@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0", "@typescript-eslint/parser": "^3.9.0",
"eslint": "^7.7.0", "eslint": "^7.7.0",

View File

@ -0,0 +1,8 @@
import slug from 'slugify';
export function slugify(str: string): string {
return slug(str, {
replacement: '-',
lower: true,
});
}

View File

@ -4,11 +4,12 @@ import { Logger } from '../../commons/logger/logger';
import { UploadOptions } from './upload-options'; import { UploadOptions } from './upload-options';
import { uploadArchive } from './upload-archive'; import { uploadArchive } from './upload-archive';
import { archiveFiles } from './archive-files'; import { archiveFiles } from './archive-files';
import { v4 as uuid } from 'uuid';
const logger = new Logger('meli.cli:upload'); const logger = new Logger('meli.cli:upload');
export async function upload(options: UploadOptions): Promise<void> { export async function upload(options: UploadOptions): Promise<void> {
const archivePath = join(tmpdir(), `${options.site}-${options.release ?? 'latest'}-${options.branch}.tar.gz`); const archivePath = join(tmpdir(), `site-${uuid()}.tar.gz`);
logger.info(`Compressing files from ${options.directory}....`); logger.info(`Compressing files from ${options.directory}....`);
await archiveFiles(options.directory, archivePath); await archiveFiles(options.directory, archivePath);