create-oc 0.0.6 → 0.0.7
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/index.js +1 -0
- package/package.json +2 -1
- package/templates/solid/package.json +1 -1
- package/templates/vue/package.json +43 -0
- package/templates/vue/public/logo.png +0 -0
- package/templates/vue/src/App.vue +62 -0
- package/templates/vue/src/HelloWorld.vue +38 -0
- package/templates/vue/src/oc-app.d.ts +1 -0
- package/templates/vue/src/server.ts +36 -0
- package/templates/vue/src/setupTests.js +1 -0
- package/templates/vue/src/styles.css +30 -0
- package/templates/vue/src/types.ts +15 -0
- package/templates/vue/tsconfig.json +26 -0
- package/templates/vue/vite.config.ts +11 -0
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-oc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"create-oc": "./index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
+
"build": "node copy-scaffolds.js",
|
|
11
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [],
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "base-component-solid",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"lint": "eslint --max-warnings 0 --ext .js,.jsx,.ts,.tsx src",
|
|
7
|
+
"build": "tsc --noEmit && oc package .",
|
|
8
|
+
"test": "vitest"
|
|
9
|
+
},
|
|
10
|
+
"oc": {
|
|
11
|
+
"files": {
|
|
12
|
+
"data": "src/server.ts",
|
|
13
|
+
"template": {
|
|
14
|
+
"src": "src/App.vue",
|
|
15
|
+
"type": "oc-template-vue"
|
|
16
|
+
},
|
|
17
|
+
"static": [
|
|
18
|
+
"public"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"parameters": {
|
|
22
|
+
"userId": {
|
|
23
|
+
"default": 1,
|
|
24
|
+
"description": "The user id from the user database",
|
|
25
|
+
"example": 1,
|
|
26
|
+
"mandatory": true,
|
|
27
|
+
"type": "number"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
33
|
+
"@types/testing-library__jest-dom": "^5.14.5",
|
|
34
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
35
|
+
"jsdom": "^21.1.1",
|
|
36
|
+
"oc-server": "*",
|
|
37
|
+
"oc-template-vue-compiler": "*",
|
|
38
|
+
"typescript": "5.0.2",
|
|
39
|
+
"vitest": "^0.29.7",
|
|
40
|
+
"vue": "^3.3.11",
|
|
41
|
+
"vue-tsc": "^1.8.25"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
import logo from '../public/logo.png';
|
|
4
|
+
import { serverClient, ActionOutput } from 'oc-server'
|
|
5
|
+
const props = defineProps<{ userId: number, firstName: string, lastName: string }>()
|
|
6
|
+
|
|
7
|
+
const additionalData = ref<ActionOutput<'getMoreData'> | null>(null);
|
|
8
|
+
async function getAdditionalData() {
|
|
9
|
+
additionalData.value = await serverClient.getMoreData({ userId: props.userId });
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div className="container">
|
|
15
|
+
<img width="50" height="50" v-bind:src="logo" alt="Logo" />
|
|
16
|
+
|
|
17
|
+
<h1>
|
|
18
|
+
Hello, <span>{{ firstName }}</span> {{ lastName }}
|
|
19
|
+
</h1>
|
|
20
|
+
<div className={styles.info} v-if="additionalData">
|
|
21
|
+
<div className={styles.block}>Age: {{ additionalData.age }}</div>
|
|
22
|
+
<div className={styles.block}>
|
|
23
|
+
Hobbies:
|
|
24
|
+
<span v-for="hobby in additionalData.hobbies" :key="hobby">
|
|
25
|
+
{{ hobby.toLowerCase() }}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<button className="button" @click="getAdditionalData">
|
|
30
|
+
Get extra information
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style scoped>
|
|
36
|
+
.container {
|
|
37
|
+
background-color: #3b246c;
|
|
38
|
+
color: #fff;
|
|
39
|
+
font-family: sans-serif;
|
|
40
|
+
padding: 40px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.button {
|
|
44
|
+
background-color: #a97613;
|
|
45
|
+
border: none;
|
|
46
|
+
padding: 15px 32px;
|
|
47
|
+
text-align: center;
|
|
48
|
+
font-size: 16px;
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
display: inline-block;
|
|
51
|
+
color: inherit;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
h1 {
|
|
56
|
+
margin: 0 0 20px 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
span {
|
|
60
|
+
text-decoration: underline;
|
|
61
|
+
}
|
|
62
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineProps<{ msg: string }>()
|
|
5
|
+
|
|
6
|
+
const count = ref(0)
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<h1>{{ msg }}</h1>
|
|
11
|
+
|
|
12
|
+
<div class="card">
|
|
13
|
+
<button type="button" @click="count++">count is {{ count }}</button>
|
|
14
|
+
<p>
|
|
15
|
+
Edit
|
|
16
|
+
<code>components/HelloWorld.vue</code> to test HMR
|
|
17
|
+
</p>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<p>
|
|
21
|
+
Check out
|
|
22
|
+
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
|
23
|
+
>create-vue</a
|
|
24
|
+
>, the official Vue + Vite starter
|
|
25
|
+
</p>
|
|
26
|
+
<p>
|
|
27
|
+
Install
|
|
28
|
+
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
|
|
29
|
+
in your IDE for a better DX
|
|
30
|
+
</p>
|
|
31
|
+
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<style scoped>
|
|
35
|
+
.read-the-docs {
|
|
36
|
+
color: #888;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="oc-vite/client" />
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Server } from 'oc-server';
|
|
2
|
+
import { ClientProps, OcParameters } from './types';
|
|
3
|
+
|
|
4
|
+
const database = [
|
|
5
|
+
{ name: 'John Doe', age: 34, hobbies: ['Swimming', 'Basketball'] },
|
|
6
|
+
{ name: 'Jane Doe', age: 35, hobbies: ['Running', 'Rugby'] }
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
async function getUser(userId: number) {
|
|
10
|
+
return database[userId];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const server = new Server(async (params: OcParameters): Promise<ClientProps> => {
|
|
14
|
+
const { userId } = params;
|
|
15
|
+
const user = await getUser(userId);
|
|
16
|
+
|
|
17
|
+
const [firstName, lastName] = user.name.split(/\s+/);
|
|
18
|
+
return {
|
|
19
|
+
userId,
|
|
20
|
+
firstName,
|
|
21
|
+
lastName
|
|
22
|
+
};
|
|
23
|
+
}).action('getMoreData', async (params: OcParameters) => {
|
|
24
|
+
const { userId } = params;
|
|
25
|
+
const user = await getUser(userId);
|
|
26
|
+
return {
|
|
27
|
+
age: user.age,
|
|
28
|
+
hobbies: user.hobbies
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
declare module 'oc-server' {
|
|
33
|
+
interface Register {
|
|
34
|
+
server: typeof server;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
background-color: #3b246c;
|
|
3
|
+
color: #fff;
|
|
4
|
+
font-family: sans-serif;
|
|
5
|
+
padding: 40px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.button {
|
|
9
|
+
background-color: #a97613;
|
|
10
|
+
border: none;
|
|
11
|
+
padding: 15px 32px;
|
|
12
|
+
text-align: center;
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
display: inline-block;
|
|
16
|
+
color: inherit;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.info {
|
|
21
|
+
margin-bottom: 20px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.block {
|
|
25
|
+
margin: 6px 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.button:hover {
|
|
29
|
+
background-color: #c79535;
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface OcParameters {
|
|
2
|
+
userId: number;
|
|
3
|
+
getMoreData?: boolean;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AdditionalData {
|
|
7
|
+
hobbies: string[];
|
|
8
|
+
age: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ClientProps extends Partial<AdditionalData> {
|
|
12
|
+
userId: number;
|
|
13
|
+
firstName: string;
|
|
14
|
+
lastName: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// These are suggested values and will be set when not present in the
|
|
4
|
+
// tsconfig.json
|
|
5
|
+
// 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()
|
|
6
|
+
"target": "es5",
|
|
7
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"allowSyntheticDefaultImports": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"noFallthroughCasesInSwitch": true,
|
|
15
|
+
|
|
16
|
+
// These values are required and cannot be changed by the user
|
|
17
|
+
// Keep this in sync with the rollup config
|
|
18
|
+
"module": "esnext",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"isolatedModules": true,
|
|
22
|
+
"jsx": "preserve"
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
25
|
+
"exclude": ["src/_package"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
// https://vitejs.dev/config/
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// Add your own plugins here for thinkgs like eslint or typecheckers
|
|
6
|
+
plugins: [],
|
|
7
|
+
// @ts-ignore Missing test property
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom'
|
|
10
|
+
}
|
|
11
|
+
});
|