proteum 1.0.0 → 1.0.2
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/cli/app/config.ts +54 -0
- package/cli/app/index.ts +195 -0
- package/cli/bin.js +35 -0
- package/cli/commands/build.ts +34 -0
- package/cli/commands/deploy/app.ts +29 -0
- package/cli/commands/deploy/web.ts +60 -0
- package/cli/commands/dev.ts +109 -0
- package/cli/commands/init.ts +85 -0
- package/cli/compiler/client/identite.ts +72 -0
- package/cli/compiler/client/index.ts +335 -0
- package/cli/compiler/common/babel/index.ts +170 -0
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +586 -0
- package/cli/compiler/common/babel/routes/imports.ts +127 -0
- package/cli/compiler/common/babel/routes/routes.ts +1130 -0
- package/cli/compiler/common/files/autres.ts +39 -0
- package/cli/compiler/common/files/images.ts +42 -0
- package/cli/compiler/common/files/style.ts +80 -0
- package/cli/compiler/common/index.ts +160 -0
- package/cli/compiler/index.ts +564 -0
- package/cli/compiler/server/index.ts +211 -0
- package/cli/index.ts +189 -0
- package/cli/paths.ts +165 -0
- package/cli/print.ts +12 -0
- package/cli/tsconfig.json +42 -0
- package/cli/utils/index.ts +22 -0
- package/cli/utils/keyboard.ts +78 -0
- package/client/app/index.ts +2 -0
- package/client/components/Dialog/Manager.tsx +3 -49
- package/client/components/Dialog/index.less +3 -1
- package/client/components/index.ts +1 -2
- package/client/services/router/index.tsx +6 -16
- package/common/errors/index.tsx +12 -31
- package/doc/TODO.md +1 -1
- package/package.json +58 -20
- package/server/app/container/console/index.ts +1 -1
- package/server/services/auth/index.ts +62 -27
- package/server/services/auth/router/request.ts +17 -6
- package/server/services/router/http/index.ts +1 -1
- package/server/services/router/response/index.ts +1 -1
- package/server/services/schema/request.ts +28 -10
- package/tsconfig.common.json +2 -1
- package/changelog.md +0 -5
- package/client/components/Button.tsx +0 -298
- package/client/components/Dialog/card.tsx +0 -208
- package/client/data/input.ts +0 -32
- package/client/pages/bug.tsx.old +0 -60
- package/templates/composant.tsx +0 -40
- package/templates/form.ts +0 -30
- package/templates/modal.tsx +0 -47
- package/templates/modele.ts +0 -56
- package/templates/page.tsx +0 -74
- package/templates/route.ts +0 -43
- package/templates/service.ts +0 -75
- package/vscode/copyimportationpath/.eslintrc.json +0 -24
- package/vscode/copyimportationpath/.vscodeignore +0 -12
- package/vscode/copyimportationpath/CHANGELOG.md +0 -9
- package/vscode/copyimportationpath/README.md +0 -3
- package/vscode/copyimportationpath/copyimportationpath-0.0.1.vsix +0 -0
- package/vscode/copyimportationpath/out/extension.js +0 -206
- package/vscode/copyimportationpath/out/extension.js.map +0 -1
- package/vscode/copyimportationpath/package-lock.json +0 -4536
- package/vscode/copyimportationpath/package.json +0 -86
- package/vscode/copyimportationpath/src/extension.ts +0 -300
- package/vscode/copyimportationpath/tsconfig.json +0 -22
- package/vscode/copyimportationpath/vsc-extension-quickstart.md +0 -42
package/client/pages/bug.tsx.old
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
// Npm
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
// Core components
|
|
8
|
-
import { Button, Input } from '@client/components';
|
|
9
|
-
import Card, { Props as CardProps } from '@client/components/Dialog/card';
|
|
10
|
-
|
|
11
|
-
// Core libs
|
|
12
|
-
import useContext from '@/client/context';
|
|
13
|
-
|
|
14
|
-
/*----------------------------------
|
|
15
|
-
- TYPES
|
|
16
|
-
----------------------------------*/
|
|
17
|
-
|
|
18
|
-
export default ({ ...self }: {} & CardProps) => {
|
|
19
|
-
|
|
20
|
-
const { api, modal, clientBug } = useContext();
|
|
21
|
-
|
|
22
|
-
const [observation, setObservation] = React.useState("");
|
|
23
|
-
const [before, setBefore] = React.useState("");
|
|
24
|
-
|
|
25
|
-
const send = () => clientBug({ observation, before }).then(() =>
|
|
26
|
-
modal.success("Thanks You !", `Your bug report will be review in the next 12 hours.`).then(() =>
|
|
27
|
-
self.close(true)
|
|
28
|
-
)
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const close = () => modal.confirm("Cancel your report ?", "All your changes will not be saved.").then(close =>
|
|
32
|
-
close && self.close(true)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
self.onClose = close
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Card {...self} title="Report a problem" footer={<>
|
|
39
|
-
|
|
40
|
-
<Button onClick={() => close()}>
|
|
41
|
-
Cancel
|
|
42
|
-
</Button>
|
|
43
|
-
|
|
44
|
-
<Button type="primary" onClick={send}>
|
|
45
|
-
Send Report
|
|
46
|
-
</Button>
|
|
47
|
-
|
|
48
|
-
</>}>
|
|
49
|
-
|
|
50
|
-
<p>What's the problem ?</p>
|
|
51
|
-
|
|
52
|
-
<Input type="longtext" title="Description of the problem" value={observation} onChange={setObservation} />
|
|
53
|
-
|
|
54
|
-
<p>What did you do just before the problem occurs ?</p>
|
|
55
|
-
|
|
56
|
-
<Input type="longtext" title="How the problem occured ?" value={before} onChange={setBefore} />
|
|
57
|
-
|
|
58
|
-
</Card>
|
|
59
|
-
)
|
|
60
|
-
}
|
package/templates/composant.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Regex: \/[A-Z][a-zA-Z]+(\/index)?\.tsx$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDENCIES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Npm
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
// Core libs
|
|
11
|
-
import useContext from '@/client/context';
|
|
12
|
-
|
|
13
|
-
// Core components
|
|
14
|
-
import Button from '@client/components/Button';
|
|
15
|
-
|
|
16
|
-
// App
|
|
17
|
-
|
|
18
|
-
/*----------------------------------
|
|
19
|
-
- TYPES
|
|
20
|
-
----------------------------------*/
|
|
21
|
-
|
|
22
|
-
type Props = {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/*----------------------------------
|
|
27
|
-
- COMPONENT
|
|
28
|
-
----------------------------------*/
|
|
29
|
-
export default ({ }: Props) => {
|
|
30
|
-
|
|
31
|
-
const { api, user } = useContext();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div>
|
|
35
|
-
|
|
36
|
-
</div>
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
package/templates/form.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Regex: \/common\/forms\/.+\.ts$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Core libs
|
|
8
|
-
import schema from '@validator';
|
|
9
|
-
|
|
10
|
-
// Core components
|
|
11
|
-
import Input from '@client/components/input';
|
|
12
|
-
|
|
13
|
-
/*----------------------------------
|
|
14
|
-
- TYPES
|
|
15
|
-
----------------------------------*/
|
|
16
|
-
|
|
17
|
-
export type TFormData = {
|
|
18
|
-
email: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/*----------------------------------
|
|
22
|
-
- VALIDTEURS
|
|
23
|
-
----------------------------------*/
|
|
24
|
-
// Rappel: Les validateurs associés au type de la propriété sont executés en priorité
|
|
25
|
-
export default schema.new({
|
|
26
|
-
email: schema.string({
|
|
27
|
-
rendu: Input,
|
|
28
|
-
titre: "Your Email Address",
|
|
29
|
-
}),
|
|
30
|
-
})
|
package/templates/modal.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Regex: \/Modal([A-Z][a-zA-Z]+)?\.tsx$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Npm
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
// Cre libs
|
|
11
|
-
import useContext from '@/client/context';
|
|
12
|
-
|
|
13
|
-
// Core components
|
|
14
|
-
import Card, { Props as CardProps } from '@client/components/Dialog/card';
|
|
15
|
-
import Button from '@client/components/Button';
|
|
16
|
-
|
|
17
|
-
/*----------------------------------
|
|
18
|
-
- COMPOSANT
|
|
19
|
-
----------------------------------*/
|
|
20
|
-
export default ({ close, ...props }: Partial<CardProps>) => {
|
|
21
|
-
|
|
22
|
-
const { api, modal } = useContext();
|
|
23
|
-
|
|
24
|
-
const send = () => api.post('/auth/getinvite', { }).then(() => {
|
|
25
|
-
|
|
26
|
-
modal.success('Yeah !', "It's ok");
|
|
27
|
-
close(true);
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div class="card col" title="Hello" {...props}>
|
|
33
|
-
|
|
34
|
-
<header class="row">
|
|
35
|
-
<h2>Hello</h2>
|
|
36
|
-
</header>
|
|
37
|
-
|
|
38
|
-
<p>This is a text</p>
|
|
39
|
-
|
|
40
|
-
<footer class="row actions fill">
|
|
41
|
-
<Button iconR="long-arrow-right" async onClick={send}>
|
|
42
|
-
Continue
|
|
43
|
-
</Button>
|
|
44
|
-
</footer>
|
|
45
|
-
</div>
|
|
46
|
-
)
|
|
47
|
-
}
|
package/templates/modele.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Regex: \/server\/models\/.+\.ts$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
import Modele, {
|
|
7
|
-
// Définitions
|
|
8
|
-
Table, Column, API, Scopes,
|
|
9
|
-
// Associations
|
|
10
|
-
HasOne, HasMany
|
|
11
|
-
} from '@serveur/database/modele';
|
|
12
|
-
|
|
13
|
-
import Query from '@serveur/database/jsql/query/runner';
|
|
14
|
-
|
|
15
|
-
/*----------------------------------
|
|
16
|
-
- IMPORTATIONS TYPES
|
|
17
|
-
----------------------------------*/
|
|
18
|
-
|
|
19
|
-
import { Utilisateur } from '@modeles';
|
|
20
|
-
|
|
21
|
-
/*----------------------------------
|
|
22
|
-
- DEFINITIONS TYPES
|
|
23
|
-
----------------------------------*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/*----------------------------------
|
|
27
|
-
- MODELE
|
|
28
|
-
----------------------------------*/
|
|
29
|
-
@Scopes([])
|
|
30
|
-
@Table('content', 'ModuleNames')
|
|
31
|
-
export default class ModuleName extends Modele {
|
|
32
|
-
|
|
33
|
-
/*----------------------------------
|
|
34
|
-
- IDENTIFICATION
|
|
35
|
-
----------------------------------*/
|
|
36
|
-
@API() @Column()
|
|
37
|
-
public id!: number;
|
|
38
|
-
|
|
39
|
-
/*----------------------------------
|
|
40
|
-
- AFFICHAGE
|
|
41
|
-
----------------------------------*/
|
|
42
|
-
|
|
43
|
-
@API() @Column()
|
|
44
|
-
public titre!: string;
|
|
45
|
-
|
|
46
|
-
@Column()
|
|
47
|
-
public createur_id!: number;
|
|
48
|
-
@API() @HasOne(() => Utilisateur, { fk: 'createur_id' })
|
|
49
|
-
public createur?: Utilisateur;
|
|
50
|
-
|
|
51
|
-
/*----------------------------------
|
|
52
|
-
- SCOPES
|
|
53
|
-
----------------------------------*/
|
|
54
|
-
/*public static StatusStatic = () =>
|
|
55
|
-
new Query<ModuleName>(Scope, {})*/
|
|
56
|
-
}
|
package/templates/page.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Regex: \/client\/pages\/(?<PATH>.+)\.tsx$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Npm
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
// Core
|
|
11
|
-
import route from '@router';
|
|
12
|
-
import { useState } from '@/client/context';
|
|
13
|
-
|
|
14
|
-
// Core components
|
|
15
|
-
import Button from '@client/components/Button';
|
|
16
|
-
|
|
17
|
-
// App
|
|
18
|
-
import Page from '@client/pages/_layout/app/Page';
|
|
19
|
-
import type { NAME } from '@/server/libs/PATH';
|
|
20
|
-
|
|
21
|
-
/*----------------------------------
|
|
22
|
-
- CONTROLEUR
|
|
23
|
-
----------------------------------*/
|
|
24
|
-
route.page('/PATH', { }, ({}, { api }) => ({
|
|
25
|
-
|
|
26
|
-
NAMELOWERs: api.get('/PATH')
|
|
27
|
-
|
|
28
|
-
}), ({ NAMELOWERs }, { api, modal, toast, user }) => {
|
|
29
|
-
|
|
30
|
-
/*----------------------------------
|
|
31
|
-
- STATE
|
|
32
|
-
----------------------------------*/
|
|
33
|
-
|
|
34
|
-
const [{ state }, setState] = useState<{
|
|
35
|
-
state: string
|
|
36
|
-
}>({
|
|
37
|
-
state: ""
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/*----------------------------------
|
|
41
|
-
- ACTIONS
|
|
42
|
-
----------------------------------*/
|
|
43
|
-
|
|
44
|
-
const action = () => api.post('/PATH', { }).then(() => {
|
|
45
|
-
modal.success('Yeah !', "It's ok");
|
|
46
|
-
close(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/*----------------------------------
|
|
50
|
-
- RENDER
|
|
51
|
-
----------------------------------*/
|
|
52
|
-
return (
|
|
53
|
-
<Page breadcrumb={{ Parent: null }} title="NAME" subtitle="Subtitle" actions={<>
|
|
54
|
-
|
|
55
|
-
<ul id="actions" class="row al-left wrap">
|
|
56
|
-
|
|
57
|
-
<li class="row stat m card color-1">
|
|
58
|
-
<i src="wallet" class="solid" />
|
|
59
|
-
<div class="label">
|
|
60
|
-
Name
|
|
61
|
-
<strong>Number</strong>
|
|
62
|
-
</div>
|
|
63
|
-
</li>
|
|
64
|
-
|
|
65
|
-
</ul>
|
|
66
|
-
|
|
67
|
-
</>}>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</Page>
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
});
|
package/templates/route.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Regex: \/server\/routes\/(?<PATH>.+)\.ts$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Core
|
|
8
|
-
import route from '@router';
|
|
9
|
-
|
|
10
|
-
// App
|
|
11
|
-
import NAME from '@/server/libs/PATH';
|
|
12
|
-
|
|
13
|
-
/*----------------------------------
|
|
14
|
-
- ROUTES
|
|
15
|
-
----------------------------------*/
|
|
16
|
-
|
|
17
|
-
route.get('/PATH', async ({ user, request }) => {
|
|
18
|
-
|
|
19
|
-
return await NAME.List(user, false, request);
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
route.get('/PATH/:id', async ({ schema, user }) => {
|
|
24
|
-
|
|
25
|
-
const { id } = await schema.validate({
|
|
26
|
-
id: schema.string()
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return await NAME.Get(id, user);
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
route.post('/PATH/:id', async ({ auth, schema }) => {
|
|
34
|
-
|
|
35
|
-
const user = await auth.check("USER");
|
|
36
|
-
|
|
37
|
-
const { id } = await schema.validate({
|
|
38
|
-
id: schema.string(),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return await NAME.Action(id, user);
|
|
42
|
-
|
|
43
|
-
});
|
package/templates/service.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Regex: \/server\/libs\/.+\.ts$
|
|
2
|
-
|
|
3
|
-
/*----------------------------------
|
|
4
|
-
- DEPENDANCES
|
|
5
|
-
----------------------------------*/
|
|
6
|
-
|
|
7
|
-
// Npm
|
|
8
|
-
|
|
9
|
-
// Core
|
|
10
|
-
import { $ } from '@server/app';
|
|
11
|
-
|
|
12
|
-
// App
|
|
13
|
-
import User from '@/server/models';
|
|
14
|
-
|
|
15
|
-
/*----------------------------------
|
|
16
|
-
- CONFIG
|
|
17
|
-
----------------------------------*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/*----------------------------------
|
|
22
|
-
- TYPES
|
|
23
|
-
----------------------------------*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/*----------------------------------
|
|
27
|
-
- SERVICE
|
|
28
|
-
----------------------------------*/
|
|
29
|
-
class NAMEs {
|
|
30
|
-
|
|
31
|
-
/*----------------------------------
|
|
32
|
-
- INFORMATIONS
|
|
33
|
-
----------------------------------*/
|
|
34
|
-
public async List( user: User | null ): Promise<NAME[]> {
|
|
35
|
-
|
|
36
|
-
const NAMELOWER = await $.sql<NAME>`
|
|
37
|
-
SELECT
|
|
38
|
-
id
|
|
39
|
-
FROM core.NAME
|
|
40
|
-
ORDER BY date DESC
|
|
41
|
-
LIMIT 25
|
|
42
|
-
`.all();
|
|
43
|
-
|
|
44
|
-
return NAMELOWER;
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public async Get( id: string, user: User ): Promise<NAME> {
|
|
49
|
-
|
|
50
|
-
const NAMELOWERs = await $.sql<NAME>`
|
|
51
|
-
SELECT
|
|
52
|
-
id
|
|
53
|
-
FROM core.NAME
|
|
54
|
-
WHERE id = ${id}
|
|
55
|
-
`.firstOrFail();
|
|
56
|
-
|
|
57
|
-
return NAMELOWERs;
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/*----------------------------------
|
|
62
|
-
- ACTIONS
|
|
63
|
-
----------------------------------*/
|
|
64
|
-
public async Action( id: string, user: User ): Promise<NAME> {
|
|
65
|
-
|
|
66
|
-
const NAMELOWER = await this.Get(id, user);
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default new NAMEs
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"parserOptions": {
|
|
5
|
-
"ecmaVersion": 6,
|
|
6
|
-
"sourceType": "module"
|
|
7
|
-
},
|
|
8
|
-
"plugins": [
|
|
9
|
-
"@typescript-eslint"
|
|
10
|
-
],
|
|
11
|
-
"rules": {
|
|
12
|
-
"@typescript-eslint/naming-convention": "warn",
|
|
13
|
-
"@typescript-eslint/semi": "warn",
|
|
14
|
-
"curly": "warn",
|
|
15
|
-
"eqeqeq": "warn",
|
|
16
|
-
"no-throw-literal": "warn",
|
|
17
|
-
"semi": "off"
|
|
18
|
-
},
|
|
19
|
-
"ignorePatterns": [
|
|
20
|
-
"out",
|
|
21
|
-
"dist",
|
|
22
|
-
"**/*.d.ts"
|
|
23
|
-
]
|
|
24
|
-
}
|
|
Binary file
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.deactivate = exports.activate = void 0;
|
|
13
|
-
const vscode = require("vscode");
|
|
14
|
-
const fs = require('fs');
|
|
15
|
-
const json5 = require('json5');
|
|
16
|
-
const path = require('path');
|
|
17
|
-
var minimatch = require("minimatch");
|
|
18
|
-
function activate(context) {
|
|
19
|
-
const regEntete = /^\/\/\s+([a-z]+)\:\s+(.+)/i;
|
|
20
|
-
const templates = {};
|
|
21
|
-
const dossierTemplates = path.join(context.extensionPath, '../..', 'templates');
|
|
22
|
-
if (!fs.existsSync(dossierTemplates)) {
|
|
23
|
-
console.log("Template folder not existing:", dossierTemplates);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
//const dossierTemplates = workspace + '/../node_modules/@dopamyn/framework/templates';
|
|
27
|
-
fs.readdir(dossierTemplates, (err, files) => {
|
|
28
|
-
console.log("Lecture de", dossierTemplates, files);
|
|
29
|
-
if (err)
|
|
30
|
-
return console.error(err);
|
|
31
|
-
for (const file of files) {
|
|
32
|
-
const nom = file.substring(0, file.lastIndexOf('.'));
|
|
33
|
-
let content = fs.readFileSync(dossierTemplates + '/' + file, { encoding: 'utf-8' });
|
|
34
|
-
const entete = regEntete.exec(content);
|
|
35
|
-
if (!entete) {
|
|
36
|
-
console.error(file + `: Entete manquante ou au mauvais format.`);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
console.log('Template', file, nom, entete[1], entete[2]);
|
|
40
|
-
// Retire l'entete de la template
|
|
41
|
-
content = content.substring(entete[0].length).trim();
|
|
42
|
-
templates[nom] = { content };
|
|
43
|
-
if (entete[1] === 'Glob')
|
|
44
|
-
templates[nom].glob = entete[2];
|
|
45
|
-
else if (entete[1] === 'Regex')
|
|
46
|
-
templates[nom].regex = new RegExp(entete[2]);
|
|
47
|
-
else
|
|
48
|
-
console.error(file + `: Entete inconnue: ` + entete[1]);
|
|
49
|
-
}
|
|
50
|
-
console.log(templates);
|
|
51
|
-
});
|
|
52
|
-
vscode.workspace.onDidCreateFiles((e) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
for (const file of e.files) {
|
|
54
|
-
const importPath = yield getImportPath(file.path);
|
|
55
|
-
const importName = getImportName(importPath, file.path);
|
|
56
|
-
console.log("Fichier créé:", file.path, importPath);
|
|
57
|
-
// Remplacements
|
|
58
|
-
for (const nom in templates) {
|
|
59
|
-
const { glob, regex, content } = templates[nom];
|
|
60
|
-
let match;
|
|
61
|
-
if ((glob && minimatch(file.path, glob)) || (match = regex === null || regex === void 0 ? void 0 : regex.exec(file.path))) {
|
|
62
|
-
const remplacements = Object.assign({ NAMELOWER: importName.toLowerCase(), NAME: importName, ABSPATH: importPath }, ((match === null || match === void 0 ? void 0 : match.groups) || {}));
|
|
63
|
-
console.log("Template:", nom, "Remplacements:", remplacements);
|
|
64
|
-
fs.writeFileSync(file.path, content.replace(new RegExp(Object.keys(remplacements).join('|'), 'g'), (match) => remplacements[match]));
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
const readTsConfig = (chemin, workspace) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
var _a;
|
|
72
|
-
console.log('Lecture de ' + chemin);
|
|
73
|
-
const rawtsconfig = fs.readFileSync(chemin, { encoding: 'utf-8' });
|
|
74
|
-
const tsconfig = json5.parse(rawtsconfig);
|
|
75
|
-
const paths = (_a = tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths;
|
|
76
|
-
if (paths !== undefined) {
|
|
77
|
-
// Les plus specifiques en premiers
|
|
78
|
-
let retour = [];
|
|
79
|
-
for (let alias in paths) {
|
|
80
|
-
let chemin = path.join(workspace, paths[alias][0]);
|
|
81
|
-
const partiel = chemin.endsWith('*');
|
|
82
|
-
if (partiel) {
|
|
83
|
-
// Retire le * à la fin
|
|
84
|
-
chemin = chemin.substring(0, chemin.length - 1);
|
|
85
|
-
alias = alias.substring(0, alias.length - 1);
|
|
86
|
-
}
|
|
87
|
-
retour.push({
|
|
88
|
-
partiel,
|
|
89
|
-
alias,
|
|
90
|
-
chemin
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
retour.sort((a, b) => b.chemin.length - a.chemin.length);
|
|
94
|
-
return retour;
|
|
95
|
-
}
|
|
96
|
-
else if (tsconfig.extends !== undefined)
|
|
97
|
-
return yield readTsConfig(path.resolve(path.dirname(chemin), tsconfig.extends), workspace);
|
|
98
|
-
else
|
|
99
|
-
return [];
|
|
100
|
-
});
|
|
101
|
-
const removeExtensions = (fichier, extensions) => {
|
|
102
|
-
for (const extension of extensions) {
|
|
103
|
-
console.log(extension, fichier);
|
|
104
|
-
if (fichier.endsWith('.' + extension)) {
|
|
105
|
-
fichier = fichier.substring(0, fichier.length - extension.length - 1);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (fichier.endsWith('/index'))
|
|
110
|
-
fichier = fichier.substring(0, fichier.length - 6);
|
|
111
|
-
return fichier;
|
|
112
|
-
};
|
|
113
|
-
const getListeAlias = () => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
var _b;
|
|
115
|
-
if (!((_b = vscode.workspace.workspaceFolders) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
116
|
-
console.error(`Impossible de récupérer le dossier du workspace actuel`);
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
|
-
const workspace = vscode.workspace.workspaceFolders[0].uri.path;
|
|
120
|
-
const tsconfigs = yield vscode.workspace.findFiles('tsconfig.json');
|
|
121
|
-
if (tsconfigs.length === 0)
|
|
122
|
-
return [];
|
|
123
|
-
return yield readTsConfig(tsconfigs[0].path, workspace);
|
|
124
|
-
});
|
|
125
|
-
const getImportPath = (fichier) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const listeAlias = yield getListeAlias();
|
|
127
|
-
console.log('fichier =', fichier);
|
|
128
|
-
console.log('listeAlias =', listeAlias);
|
|
129
|
-
for (const alias of listeAlias) {
|
|
130
|
-
// Remplacement prefixe
|
|
131
|
-
if (alias.partiel) {
|
|
132
|
-
if (fichier.startsWith(alias.chemin)) {
|
|
133
|
-
fichier = alias.alias + fichier.substring(alias.chemin.length);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
// Remplacement complet
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
if (fichier === alias.chemin) {
|
|
140
|
-
fichier = alias.alias;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// Vire l'extension
|
|
146
|
-
fichier = removeExtensions(fichier, ['tsx', 'ts', 'js', 'jsx']);
|
|
147
|
-
return fichier;
|
|
148
|
-
});
|
|
149
|
-
const findImportPath = (selectedFile) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
let fichier;
|
|
151
|
-
if (selectedFile)
|
|
152
|
-
fichier = selectedFile.path;
|
|
153
|
-
else {
|
|
154
|
-
if (!vscode.window.activeTextEditor)
|
|
155
|
-
return console.error(`Aucun editeur actif`);
|
|
156
|
-
fichier = vscode.window.activeTextEditor.document.uri.path;
|
|
157
|
-
}
|
|
158
|
-
return yield getImportPath(fichier);
|
|
159
|
-
});
|
|
160
|
-
const getImportName = (importPath, originalPath) => {
|
|
161
|
-
const content = fs.readFileSync(originalPath, { encoding: 'utf-8' });
|
|
162
|
-
const exportdefault = /export default\s+(function|class|new)\s+([a-zA-Z]+)/.exec(content);
|
|
163
|
-
let nomModule;
|
|
164
|
-
if (exportdefault) {
|
|
165
|
-
nomModule = exportdefault[2];
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const posSlash = importPath.lastIndexOf('/');
|
|
169
|
-
nomModule = importPath.substring(posSlash === -1 ? 0 : posSlash + 1);
|
|
170
|
-
nomModule = nomModule[0].toUpperCase() + nomModule.substring(1);
|
|
171
|
-
}
|
|
172
|
-
return nomModule;
|
|
173
|
-
};
|
|
174
|
-
const copier = (txt) => {
|
|
175
|
-
console.log(txt);
|
|
176
|
-
vscode.env.clipboard.writeText(txt);
|
|
177
|
-
//vscode.window.showInformationMessage('Copied ' + txt);
|
|
178
|
-
};
|
|
179
|
-
context.subscriptions.push(vscode.commands.registerCommand('copyimportationpath.copy', (selected) => __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
try {
|
|
181
|
-
const fichier = yield findImportPath(selected);
|
|
182
|
-
if (fichier)
|
|
183
|
-
copier(fichier);
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
vscode.window.showErrorMessage(error.toString());
|
|
187
|
-
console.error(error);
|
|
188
|
-
}
|
|
189
|
-
})), vscode.commands.registerCommand('copyimportationpath.copyStatement', (selected) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
try {
|
|
191
|
-
const importPath = yield findImportPath(selected);
|
|
192
|
-
if (importPath) {
|
|
193
|
-
const importName = getImportName(importPath, selected.path);
|
|
194
|
-
copier(`import ${importName} from '${importPath}';`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
vscode.window.showErrorMessage(error.toString());
|
|
199
|
-
console.error(error);
|
|
200
|
-
}
|
|
201
|
-
})));
|
|
202
|
-
}
|
|
203
|
-
exports.activate = activate;
|
|
204
|
-
function deactivate() { }
|
|
205
|
-
exports.deactivate = deactivate;
|
|
206
|
-
//# sourceMappingURL=extension.js.map
|