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

Fixed support for hpt file type and added stage CI/CD pipeline. #558

Merged
merged 5 commits into from
Apr 2, 2024
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
26 changes: 26 additions & 0 deletions .github/workflows/deploy_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: filestack-js-stage
on:
push:
branches: [ stage ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup repository env
uses: actions/setup-node@v1
with:
node-version: '14.x'
registry-url: "https://registry.npmjs.org"
- name: Install deps
run: npm install --ignore-scripts
- name: Run tests
run: npm test
- name: Prepare docs
run: npm run docs
- name: Publish package to cdn - stage version
run: npm run publish:s3:stage
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"release": "standard-version",
"prepare": "npm run build",
"publish:s3:beta": "npm run build && node scripts/publish.js --beta",
"publish:s3:stage": "npm run build && node scripts/publish.js --stage",
"publish:s3": "node scripts/publish.js --current --latest",
"cache:clean": "node scripts/cache.js --current --latest",
"cache:clean:beta": "node scripts/cache.js --beta",
Expand Down
5 changes: 5 additions & 0 deletions scripts/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ const purge = (bucket, path) => {
paths.push(`filestack-js/beta`)
}

if (args.indexOf('--stage') > -1) {
console.log(`clearing cache for stage version`);
paths.push(`filestack-js/stage`)
}

Promise.all(paths.map((p) => purge(bucket, p)), (res) => console.log(res))
})();
9 changes: 9 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,14 @@ const upload = async (bucket, path, cacheControll) => {
})
}

if (args.indexOf('--stage') > -1) {
console.log(`publish stage version`);
paths.push({
bucket,
path: `filestack-js/stage`,
cacheControll: 0
})
}

Promise.all(paths.map((data) => upload(data.bucket, data.path, data.cacheControll))).then((res) => console.log(res))
})();
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @private
*/
const PICKER_VERSION = '1.27.0';
const PICKER_VERSION = '1.27.1';

/**
* @private
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const ExtensionsMap = {
'mxd',
'indd',
'vsm',
'hpt',
],
'application/oda': ['oda'],
'application/oebps-package+xml': ['opf'],
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,21 @@ export const uniqueId = (len: number = 10): string => {
*/
export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Promise<string> => {
let type;

try {
type = await fromBuffer(file);
} catch(e) {
console.warn("An exception occurred while processing the buffer:", e.message);
}

if (name && name.indexOf('.') > -1) {
const mime = extensionToMime(name);

if (mime) {
return mime;
}
}

const excludedMimetypes = ['text/plain', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip'];

if (type && excludedMimetypes.indexOf(type.mime) === -1) {
Expand All @@ -137,6 +140,7 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom
return type.mime;
}

return 'application/octet-stream';
};

/**
Expand Down
Loading