You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cosmic is the free and open source ui design suite. It supports the entirety of the prototype, visual design, animation, component package and code release.
9
8
10
-
11
9
## Get started
12
10
13
11
### Continuous Integration
14
-
- The configured workflow will check the types for each push and PR.
15
-
- The configured workflow will check the code style for each push and PR.
16
-
- Unit tests are placed within each package and run separately.
17
-
- End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].
12
+
13
+
- The configured workflow will check the types for each push and PR.
14
+
- The configured workflow will check the code style for each push and PR.
15
+
- Unit tests are placed within each package and run separately.
16
+
- End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].
18
17
19
18
### Continuous delivery
20
-
- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a release draft.
21
-
- The version is automatically set based on the current date in the format `yy.mm.dd-minutes`.
22
-
- Notes are automatically generated and added to the release draft.
23
-
- Code signing supported. See [`compile` job in the `release` workflow](.github/workflows/release.yml).
24
-
-**Auto-update is supported**. After the release is published, all client applications will download the new version and install updates silently.
19
+
20
+
- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a release draft.
21
+
- The version is automatically set based on the current date in the format `yy.mm.dd-minutes`.
22
+
- Notes are automatically generated and added to the release draft.
23
+
- Code signing supported. See [`compile` job in the `release` workflow](.github/workflows/release.yml).
24
+
-**Auto-update is supported**. After the release is published, all client applications will download the new version and install updates silently.
25
25
26
26
### Project Structure
27
27
28
28
The structure of this template is very similar to the structure of a monorepo.
29
29
30
30
The entire source code of the program is divided into three modules (packages) that are each bundled independently:
31
-
-[`packages/app`](packages/app)
32
-
Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file).
33
-
-[`packages/preload`](packages/preload)
34
-
Used in `BrowserWindow.webPreferences.preload`. See [Checklist: Security Recommendations](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content).
35
-
-[`packages/site`](packages/site)
36
-
Electron [**web page**](https://www.electronjs.org/docs/tutorial/quick-start#create-a-web-page).
37
-
-[`packages/core`](packages/core)
38
-
Core libs for cosmic.
39
-
-[`packages/module`](packages/module)
40
-
Modules for cosmic.
31
+
32
+
-[`packages/app`](packages/app)
33
+
Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file).
34
+
-[`packages/preload`](packages/preload)
35
+
Used in `BrowserWindow.webPreferences.preload`. See [Checklist: Security Recommendations](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content).
36
+
-[`packages/site`](packages/site)
37
+
Electron [**web page**](https://www.electronjs.org/docs/tutorial/quick-start#create-a-web-page).
38
+
-[`packages/core`](packages/core)
39
+
Core libs for cosmic.
40
+
-[`packages/module`](packages/module)
41
+
Modules for cosmic.
41
42
42
43
### Compile App
44
+
43
45
The next step is to package and compile a ready to distribute Electron app for macOS, Windows and Linux with "auto update" support out of the box.
44
46
45
47
To do this using the [electron-builder]:
46
-
- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not ready for distribution, it is compiled only for the current platform and is used for debugging.
47
-
- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically added as a draft to the GitHub releases page.
48
+
49
+
- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not ready for distribution, it is compiled only for the current platform and is used for debugging.
50
+
- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically added as a draft to the GitHub releases page.
48
51
49
52
### Using external modules in renderer
53
+
50
54
According to [Electron's security guidelines](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content), Node.js integration is disabled for remote content. This means that **you cannot call any Node.js api in the `packages/site` directly**. This also means you can't import external modules during runtime in the renderer:
55
+
51
56
```js
52
57
// renderer.bundle.js
53
-
const {writeFile} =require('fs') // ReferenceError: require is not defined
54
-
writeFile()
58
+
const {writeFile} =require('fs');// ReferenceError: require is not defined
59
+
writeFile();
55
60
```
56
61
57
62
To use external modules in Renderer you **must** describe the interface in the `packages/preload` where the Node.js api is allowed:
63
+
58
64
```ts
59
65
// packages/preload/src/index.ts
60
-
importtype {BinaryLike} from'crypto';
61
-
import {createHash} from'crypto';
66
+
importtype {BinaryLike} from'crypto';
67
+
import {createHash} from'crypto';
62
68
63
69
contextBridge.exposeInMainWorld('nodeCrypto', {
64
-
sha256sum(data:BinaryLike) {
65
-
const hash =createHash('sha256');
66
-
hash.update(data);
67
-
returnhash.digest('hex');
68
-
},
70
+
sha256sum(data:BinaryLike) {
71
+
const hash =createHash('sha256');
72
+
hash.update(data);
73
+
returnhash.digest('hex');
74
+
},
69
75
});
70
76
```
71
77
72
78
The [`dts-cb`](https://github.com/cawa-93/dts-for-context-bridge) utility will automatically generate an interface for TS:
And now, you can safely use the registered method:
88
+
80
89
```ts
81
90
// packages/site/src/App.vue
82
-
window.nodeCrypto.sha256sum('data')
91
+
window.nodeCrypto.sha256sum('data');
83
92
```
84
93
85
94
[Read more about Security Considerations](https://www.electronjs.org/docs/tutorial/context-isolation#security-considerations).
86
95
87
-
88
96
### Modes and Environment Variables
97
+
89
98
All environment variables set as part of the `import.meta`, so you can access them as follows: `import.meta.env`.
90
99
91
100
If you are using TypeScript and want to get code completion you must add all the environment variables to the [`ImportMetaEnv` in `types/env.d.ts`](types/env.d.ts).
92
101
93
102
The mode option is used to specify the value of `import.meta.env.MODE` and the corresponding environment variables files that need to be loaded.
94
103
95
104
By default, there are two modes:
96
-
-`production` is used by default
97
-
-`development` is used by `npm run watch` script
105
+
106
+
-`production` is used by default
107
+
-`development` is used by `npm run watch` script
98
108
99
109
When running the build script, the environment variables are loaded from the following files in your project root:
100
110
@@ -111,6 +121,7 @@ To prevent accidentally leaking env variables to the client, only variables pref
111
121
DB_PASSWORD=foobar
112
122
VITE_SOME_KEY=123
113
123
```
124
+
114
125
Only `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your client source code, but `DB_PASSWORD` will not.
115
126
116
127
**Do not put any sensitive data in files managed by git, for instance database password or server address in intranet**
@@ -119,7 +130,6 @@ Only `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your
Copy file name to clipboardExpand all lines: contributing.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,13 @@ Do not create issues about bumping dependencies unless a bug has been identified
10
10
11
11
Remember that we’re here to help, but not to make guesses about what you need help with:
12
12
13
-
- Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you.
14
-
- Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library. It's important that you explain how you're using a library so that maintainers can make that connection and solve the issue.
13
+
-Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you.
14
+
-Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library. It's important that you explain how you're using a library so that maintainers can make that connection and solve the issue.
15
15
16
16
_It can't be understated how frustrating and draining it can be to maintainers to have to ask clarifying questions on the most basic things, before it's even possible to start debugging. Please try to make the best use of everyone's time involved, including yourself, by providing this information up front._
17
17
18
-
19
18
## Repo Setup
19
+
20
20
The package manager used to install and link dependencies must be npm v7 or later.
0 commit comments