@cocreate/file 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +100 -0
- package/.github/workflows/manual.yml +44 -0
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +111 -0
- package/CoCreate.config.js +27 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/demo/index.html +36 -0
- package/docs/index.html +383 -0
- package/package.json +66 -0
- package/release.config.js +22 -0
- package/src/index.js +253 -0
- package/src/upload.js +341 -0
- package/webpack.config.js +84 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
name: Automated
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
jobs:
|
|
7
|
+
about:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout
|
|
11
|
+
uses: actions/checkout@v3
|
|
12
|
+
- name: setup nodejs
|
|
13
|
+
uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: 16
|
|
16
|
+
- name: Jaid/action-sync-node-meta
|
|
17
|
+
uses: jaid/action-sync-node-meta@v1.4.0
|
|
18
|
+
with:
|
|
19
|
+
direction: overwrite-github
|
|
20
|
+
githubToken: "${{ secrets.GITHUB }}"
|
|
21
|
+
|
|
22
|
+
release:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout
|
|
26
|
+
uses: actions/checkout@v3
|
|
27
|
+
- name: setup nodejs
|
|
28
|
+
uses: actions/setup-node@v3
|
|
29
|
+
with:
|
|
30
|
+
node-version: 14
|
|
31
|
+
- name: Semantic Release
|
|
32
|
+
uses: cycjimmy/semantic-release-action@v3
|
|
33
|
+
id: semantic
|
|
34
|
+
with:
|
|
35
|
+
extra_plugins: |
|
|
36
|
+
@semantic-release/changelog
|
|
37
|
+
@semantic-release/git
|
|
38
|
+
@semantic-release/github
|
|
39
|
+
env:
|
|
40
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB }}"
|
|
41
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
42
|
+
outputs:
|
|
43
|
+
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
44
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
45
|
+
cdn:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
needs: release
|
|
48
|
+
if: needs.release.outputs.new_release_published == 'true'
|
|
49
|
+
env:
|
|
50
|
+
VERSION: "${{ needs.release.outputs.new_release_version }}"
|
|
51
|
+
steps:
|
|
52
|
+
- name: Checkout
|
|
53
|
+
uses: actions/checkout@v3
|
|
54
|
+
- name: setup nodejs
|
|
55
|
+
uses: actions/setup-node@v3
|
|
56
|
+
with:
|
|
57
|
+
node-version: 16
|
|
58
|
+
- name: yarn install
|
|
59
|
+
run: >
|
|
60
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
61
|
+
.npmrc
|
|
62
|
+
|
|
63
|
+
yarn install
|
|
64
|
+
- name: yarn build
|
|
65
|
+
run: yarn build
|
|
66
|
+
- name: upload bundle as version
|
|
67
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
68
|
+
with:
|
|
69
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
70
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
71
|
+
bucket: testcrudbucket
|
|
72
|
+
source: ./dist
|
|
73
|
+
destination: "/file/${{env.VERSION}}"
|
|
74
|
+
acl: public-read
|
|
75
|
+
- name: upload bundle as latest
|
|
76
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
77
|
+
with:
|
|
78
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
79
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
80
|
+
bucket: testcrudbucket
|
|
81
|
+
source: ./dist
|
|
82
|
+
destination: /file/latest
|
|
83
|
+
acl: public-read
|
|
84
|
+
invalidations: true
|
|
85
|
+
docs:
|
|
86
|
+
runs-on: ubuntu-latest
|
|
87
|
+
steps:
|
|
88
|
+
- name: Checkout
|
|
89
|
+
uses: actions/checkout@v3
|
|
90
|
+
- name: setup nodejs
|
|
91
|
+
uses: actions/setup-node@v3
|
|
92
|
+
with:
|
|
93
|
+
node-version: 16
|
|
94
|
+
- name: update documentation
|
|
95
|
+
uses: CoCreate-app/CoCreate-docs@master
|
|
96
|
+
env:
|
|
97
|
+
organization_id: ${{ secrets.COCREATE_ORGANIZATION_ID }}
|
|
98
|
+
key: ${{ secrets.COCREATE_KEY }}
|
|
99
|
+
host: ${{ secrets.COCREATE_HOST }}
|
|
100
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Manual Workflow
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
invalidations:
|
|
6
|
+
description: |
|
|
7
|
+
If set to 'true', invalidates previous upload.
|
|
8
|
+
default: "true"
|
|
9
|
+
required: true
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
cdn:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
env:
|
|
15
|
+
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
|
16
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB }}"
|
|
17
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v3
|
|
22
|
+
- name: setup nodejs
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: 16
|
|
26
|
+
- name: yarn install
|
|
27
|
+
run: >
|
|
28
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
29
|
+
.npmrc
|
|
30
|
+
|
|
31
|
+
yarn install
|
|
32
|
+
- name: yarn build
|
|
33
|
+
run: yarn build
|
|
34
|
+
- name: upload latest bundle
|
|
35
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
36
|
+
with:
|
|
37
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
38
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
39
|
+
distributionId: "${{ secrets.DISTRIBUTION_ID }}"
|
|
40
|
+
bucket: testcrudbucket
|
|
41
|
+
source: ./dist
|
|
42
|
+
destination: /file/latest
|
|
43
|
+
acl: public-read
|
|
44
|
+
invalidations: ${{ github.event.inputs.invalidations }}
|
package/CHANGELOG.md
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Contributing to CoCreate-file
|
|
2
|
+
|
|
3
|
+
This project is work of [many contributors](https://github.com/CoCreate-app/CoCreate-file/graphs/contributors).
|
|
4
|
+
You're encouraged to submit [pull requests](https://github.com/CoCreate-app/CoCreate-file/pulls),
|
|
5
|
+
[propose features and discuss issues](https://github.com/CoCreate-app/CoCreate-file/issues).
|
|
6
|
+
|
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
|
8
|
+
|
|
9
|
+
## Fork the Project
|
|
10
|
+
|
|
11
|
+
Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-file) and check out your copy.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
git clone https://github.com/contributor/CoCreate-file.git
|
|
15
|
+
cd CoCreate-file
|
|
16
|
+
git remote add upstream https://github.com/CoCreate-app/CoCreate-file.git
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Create a Topic Branch
|
|
20
|
+
|
|
21
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
git checkout master
|
|
25
|
+
git pull upstream master
|
|
26
|
+
git checkout -b my-feature-branch
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Write Tests
|
|
30
|
+
|
|
31
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
|
32
|
+
Add to [spec](spec).
|
|
33
|
+
|
|
34
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
35
|
+
|
|
36
|
+
## Write Code
|
|
37
|
+
|
|
38
|
+
Implement your feature or bug fix.
|
|
39
|
+
|
|
40
|
+
## Write Documentation
|
|
41
|
+
|
|
42
|
+
Document any external behavior in the [README](README.md).
|
|
43
|
+
|
|
44
|
+
## Update Changelog
|
|
45
|
+
|
|
46
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under _Next Release_.
|
|
47
|
+
Make it look like every other line, including your name and link to your Github account.
|
|
48
|
+
|
|
49
|
+
## Commit Changes
|
|
50
|
+
|
|
51
|
+
Make sure git knows your name and email address:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
git config --global user.name "Your Name"
|
|
55
|
+
git config --global user.email "contributor@example.com"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
git add ...
|
|
62
|
+
git commit
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Push
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
git push origin my-feature-branch
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Make a Pull Request
|
|
72
|
+
|
|
73
|
+
Go to [https://github.com/CoCreate-app/CoCreate-file](https://github.com/CoCreate-app/CoCreate-file) and select your feature branch.
|
|
74
|
+
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
75
|
+
|
|
76
|
+
## Rebase
|
|
77
|
+
|
|
78
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
git fetch upstream
|
|
82
|
+
git rebase upstream/master
|
|
83
|
+
git push origin my-feature-branch -f
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Update CHANGELOG Again
|
|
87
|
+
|
|
88
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
* [#123](https://github.com/CoCreate-app/CoCreate-industry/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Amend your previous commit and force push the changes.
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
git commit --amend
|
|
98
|
+
git push origin my-feature-branch -f
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Check on Your Pull Request
|
|
102
|
+
|
|
103
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
|
104
|
+
|
|
105
|
+
## Be Patient
|
|
106
|
+
|
|
107
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
|
108
|
+
|
|
109
|
+
## Thank You
|
|
110
|
+
|
|
111
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"config": {
|
|
3
|
+
"organization_id": "",
|
|
4
|
+
"key": "",
|
|
5
|
+
"host": ""
|
|
6
|
+
},
|
|
7
|
+
"sources": [
|
|
8
|
+
{
|
|
9
|
+
"collection": "files",
|
|
10
|
+
"document": {
|
|
11
|
+
"_id": "61a12db2a8b6b4001a9f5a2e",
|
|
12
|
+
"name": "index.html",
|
|
13
|
+
"path": "/docs/file/index.html",
|
|
14
|
+
"src": "{{./docs/index.html}}",
|
|
15
|
+
"hosts": [
|
|
16
|
+
"*",
|
|
17
|
+
"general.cocreate.app"
|
|
18
|
+
],
|
|
19
|
+
"directory": "/docs/file",
|
|
20
|
+
"parentDirectory": "{{parentDirectory}}",
|
|
21
|
+
"content-type": "{{content-type}}",
|
|
22
|
+
"public": "true",
|
|
23
|
+
"website_id": "644d4bff8036fb9d1d1fd69c"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 CoCreate LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# CoCreate-action
|
|
2
|
+
|
|
3
|
+
This is a configurable headless file uploader that utilizes HTML5 attributes for easy customization. With this module, users can easily upload files to a server without requiring a formal UI or browser interaction. By leveraging HTML5 attributes, it's easy to customize and fine-tune the behavior of the uploader to fit specific needs. This uploader is perfect for developers looking to implement file uploads in a headless environment. Take it for a spin in our [playground!](https://cocreate.app/docs/file)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## [Docs & Demo](https://cocreate.app/docs/file)
|
|
15
|
+
|
|
16
|
+
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/file)
|
|
17
|
+
|
|
18
|
+
## CDN
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.cocreate.app/file/latest/CoCreate-file.min.js"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://cdn.cocreate.app/file/latest/CoCreate-file.min.css"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## NPM
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
$ npm i @cocreate/file
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## yarn
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
$ yarn install @cocreate/file
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Table of Contents](#table-of-contents)
|
|
43
|
+
- [Announcements](#announcements)
|
|
44
|
+
- [Roadmap](#roadmap)
|
|
45
|
+
- [How to Contribute](#how-to-contribute)
|
|
46
|
+
- [About](#about)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
|
|
49
|
+
<a name="announcements"></a>
|
|
50
|
+
|
|
51
|
+
# Announcements
|
|
52
|
+
|
|
53
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-file/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-file/releases). You may also subscribe to email for releases and breaking changes.
|
|
54
|
+
|
|
55
|
+
<a name="roadmap"></a>
|
|
56
|
+
|
|
57
|
+
# Roadmap
|
|
58
|
+
|
|
59
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-file/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-file/pulls). We would love to hear your feedback.
|
|
60
|
+
|
|
61
|
+
<a name="about"></a>
|
|
62
|
+
|
|
63
|
+
# About
|
|
64
|
+
|
|
65
|
+
CoCreate-file is guided and supported by the CoCreate Developer Experience Team.
|
|
66
|
+
|
|
67
|
+
Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
|
|
68
|
+
|
|
69
|
+
CoCreate-file is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
70
|
+
|
|
71
|
+
<a name="contribute"></a>
|
|
72
|
+
|
|
73
|
+
# How to Contribute
|
|
74
|
+
|
|
75
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-file/blob/master/CONTRIBUTING.md) guide for details.
|
|
76
|
+
|
|
77
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-file/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-file/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
78
|
+
|
|
79
|
+
We appreciate your continued support, thank you!
|
|
80
|
+
|
|
81
|
+
<a name="license"></a>
|
|
82
|
+
|
|
83
|
+
# License
|
|
84
|
+
|
|
85
|
+
[The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-file/blob/master/LICENSE)
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>file | CoCreateJS</title>
|
|
5
|
+
|
|
6
|
+
<!-- CoCreate Favicon -->
|
|
7
|
+
<link
|
|
8
|
+
rel="icon"
|
|
9
|
+
href="https://cdn.cocreate.app/favicon.ico"
|
|
10
|
+
type="image/ico"
|
|
11
|
+
sizes="16x16" />
|
|
12
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<form>
|
|
16
|
+
<input type="file" class="fileInput" />
|
|
17
|
+
<button actions="uploadFiles">upload</button>
|
|
18
|
+
</form>
|
|
19
|
+
|
|
20
|
+
<form>
|
|
21
|
+
<input type="file" class="fileInput" multiple />
|
|
22
|
+
<button actions="uploadFiles">upload</button>
|
|
23
|
+
</form>
|
|
24
|
+
<form>
|
|
25
|
+
<input type="file" class="fileInput" directory />
|
|
26
|
+
<button actions="uploadFiles">upload</button>
|
|
27
|
+
</form>
|
|
28
|
+
<form>
|
|
29
|
+
<input type="file" class="fileInput" directory multiple />
|
|
30
|
+
<button actions="uploadFiles">upload</button>
|
|
31
|
+
</form>
|
|
32
|
+
|
|
33
|
+
<script src="../dist/CoCreate-file.js"></script>
|
|
34
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|