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

Upload .JSON files last #479

Merged
merged 2 commits into from
May 6, 2021
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
4 changes: 3 additions & 1 deletion packages/cli-lib/lib/__tests__/uploadFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('uploadFolder', () => {
'folder/templates/blog.html',
'folder/css/file.css',
'folder/js/file.js',
'folder/fields.json',
'folder/images/image.png',
'folder/images/image.jpg',
'folder/sample.module/module.css',
Expand Down Expand Up @@ -41,11 +42,12 @@ describe('uploadFolder', () => {
'folder/js/file.js',
'folder/templates/blog.html',
'folder/templates/page.html',
'folder/fields.json',
];

await uploadFolder(accountId, src, dest, { mode: 'publish' });

expect(upload).toReturnTimes(10);
expect(upload).toReturnTimes(11);

uploadedFilesInOrder.forEach((file, index) => {
expect(upload).nthCalledWith(index + 1, accountId, file, file, {
Expand Down
5 changes: 4 additions & 1 deletion packages/cli-lib/lib/uploadFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function getFilesByType(files) {
const cssAndJsFiles = [];
const otherFiles = [];
const templateFiles = [];
const jsonFiles = [];

files.forEach(file => {
const parts = splitLocalPath(file);
Expand All @@ -40,12 +41,14 @@ function getFilesByType(files) {
cssAndJsFiles.push(file);
} else if (extension === 'html') {
templateFiles.push(file);
} else if (extension === 'json') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we want to be more specific here and match only theme.json, fields.json that is not inside *.module and serverless.json.

Copy link
Contributor

@gcorne gcorne Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, that looks to be covered by how module files are already uploaded after otherFiles. Might be good to add test coverage of this either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, and I can't see a reason to treat *.functions files differently.

Adjusted test coverage to include json files

jsonFiles.push(file);
} else {
otherFiles.push(file);
}
});

return [otherFiles, moduleFiles, cssAndJsFiles, templateFiles];
return [otherFiles, moduleFiles, cssAndJsFiles, templateFiles, jsonFiles];
}
/**
*
Expand Down