create-absolutejs 0.10.0 → 0.10.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/dist/generators/configurations/generatePackageJson.d.ts +1 -1
- package/dist/generators/configurations/generatePackageJson.js +92 -14
- package/dist/generators/project/generateImportsBlock.js +3 -4
- package/dist/generators/project/scaffoldFrontends.d.ts +2 -1
- package/dist/generators/project/scaffoldFrontends.js +2 -1
- package/dist/scaffold.js +2 -1
- package/dist/templates/configurations/tsconfig.example.json +2 -8
- package/dist/templates/types/vue-shim.d.ts +10 -0
- package/dist/utils/getPackageVersion.d.ts +1 -1
- package/dist/utils/getPackageVersion.js +16 -10
- package/dist/versions.d.ts +1 -1
- package/dist/versions.js +1 -1
- package/package.json +2 -1
|
@@ -3,5 +3,5 @@ type CreatePackageJsonProps = Pick<CreateConfiguration, 'authOption' | 'useTailw
|
|
|
3
3
|
projectName: string;
|
|
4
4
|
latest: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const createPackageJson: ({ projectName, authOption, plugins, databaseEngine, orm, databaseHost, useTailwind, latest, frontendDirectories, codeQualityTool }: CreatePackageJsonProps) => void
|
|
6
|
+
export declare const createPackageJson: ({ projectName, authOption, plugins, databaseEngine, orm, databaseHost, useTailwind, latest, frontendDirectories, codeQualityTool }: CreatePackageJsonProps) => Promise<void>;
|
|
7
7
|
export {};
|
|
@@ -3,7 +3,7 @@ import { join } from 'path';
|
|
|
3
3
|
import { spinner } from '@clack/prompts';
|
|
4
4
|
import { green } from 'picocolors';
|
|
5
5
|
import { absoluteAuthPlugin, availablePlugins, defaultDependencies, defaultPlugins, eslintAndPrettierDependencies, eslintReactDependencies } from '../../data';
|
|
6
|
-
import {
|
|
6
|
+
import { getPackageVersions } from '../../utils/getPackageVersion';
|
|
7
7
|
import { versions } from '../../versions';
|
|
8
8
|
import { computeFlags } from '../project/computeFlags';
|
|
9
9
|
const dbClientCommands = {
|
|
@@ -16,15 +16,93 @@ const dbClientCommands = {
|
|
|
16
16
|
postgresql: 'psql -h localhost -U user -d database',
|
|
17
17
|
singlestore: 'singlestore -u root -ppassword -D database'
|
|
18
18
|
};
|
|
19
|
-
export const createPackageJson = ({ projectName, authOption, plugins, databaseEngine, orm, databaseHost, useTailwind, latest, frontendDirectories, codeQualityTool }) => {
|
|
19
|
+
export const createPackageJson = async ({ projectName, authOption, plugins, databaseEngine, orm, databaseHost, useTailwind, latest, frontendDirectories, codeQualityTool }) => {
|
|
20
|
+
const flags = computeFlags(frontendDirectories);
|
|
21
|
+
const isLocal = !databaseHost || databaseHost === 'none';
|
|
22
|
+
/* ── Collect all package names that need versions ─────────── */
|
|
23
|
+
const packageNames = new Set();
|
|
24
|
+
packageNames.add('typescript');
|
|
25
|
+
for (const p of defaultPlugins)
|
|
26
|
+
packageNames.add(p.value);
|
|
27
|
+
for (const dep of defaultDependencies)
|
|
28
|
+
packageNames.add(dep.value);
|
|
29
|
+
if (authOption === 'abs')
|
|
30
|
+
packageNames.add(absoluteAuthPlugin.value);
|
|
31
|
+
for (const pluginValue of plugins) {
|
|
32
|
+
const meta = availablePlugins.find((p) => p.value === pluginValue);
|
|
33
|
+
if (meta)
|
|
34
|
+
packageNames.add(meta.value);
|
|
35
|
+
}
|
|
36
|
+
if (codeQualityTool === 'eslint+prettier') {
|
|
37
|
+
for (const dep of eslintAndPrettierDependencies)
|
|
38
|
+
packageNames.add(dep.value);
|
|
39
|
+
}
|
|
40
|
+
if (useTailwind) {
|
|
41
|
+
packageNames.add('autoprefixer');
|
|
42
|
+
packageNames.add('postcss');
|
|
43
|
+
packageNames.add('tailwindcss');
|
|
44
|
+
packageNames.add('@tailwindcss/cli');
|
|
45
|
+
}
|
|
46
|
+
if (flags.requiresReact) {
|
|
47
|
+
packageNames.add('react');
|
|
48
|
+
packageNames.add('react-dom');
|
|
49
|
+
packageNames.add('@types/react');
|
|
50
|
+
}
|
|
51
|
+
if (flags.requiresReact && codeQualityTool === 'eslint+prettier') {
|
|
52
|
+
for (const dep of eslintReactDependencies)
|
|
53
|
+
packageNames.add(dep.value);
|
|
54
|
+
}
|
|
55
|
+
if (flags.requiresSvelte)
|
|
56
|
+
packageNames.add('svelte');
|
|
57
|
+
if (flags.requiresSvelte && codeQualityTool === 'eslint+prettier')
|
|
58
|
+
packageNames.add('prettier-plugin-svelte');
|
|
59
|
+
if (flags.requiresVue)
|
|
60
|
+
packageNames.add('vue');
|
|
61
|
+
if (flags.requiresHtmx)
|
|
62
|
+
packageNames.add('elysia-scoped-state');
|
|
63
|
+
if (orm === 'drizzle')
|
|
64
|
+
packageNames.add('drizzle-orm');
|
|
65
|
+
switch (databaseHost) {
|
|
66
|
+
case 'neon':
|
|
67
|
+
packageNames.add('@neondatabase/serverless');
|
|
68
|
+
break;
|
|
69
|
+
case 'planetscale':
|
|
70
|
+
packageNames.add('@planetscale/database');
|
|
71
|
+
break;
|
|
72
|
+
case 'turso':
|
|
73
|
+
packageNames.add('@libsql/client');
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
if (isLocal &&
|
|
77
|
+
(databaseEngine === 'mysql' || databaseEngine === 'mariadb') &&
|
|
78
|
+
orm === 'drizzle')
|
|
79
|
+
packageNames.add('mysql2');
|
|
80
|
+
if (isLocal && databaseEngine === 'singlestore')
|
|
81
|
+
packageNames.add('mysql2');
|
|
82
|
+
if (databaseEngine === 'postgresql' && databaseHost === 'planetscale') {
|
|
83
|
+
packageNames.add('pg');
|
|
84
|
+
packageNames.add('@types/pg');
|
|
85
|
+
}
|
|
86
|
+
if (isLocal && databaseEngine === 'mssql') {
|
|
87
|
+
packageNames.add('mssql');
|
|
88
|
+
packageNames.add('@types/mssql');
|
|
89
|
+
}
|
|
90
|
+
if (isLocal && databaseEngine === 'gel')
|
|
91
|
+
packageNames.add('gel');
|
|
92
|
+
if (databaseEngine === 'mongodb')
|
|
93
|
+
packageNames.add('mongodb');
|
|
94
|
+
/* ── Fetch all versions in parallel ──────────────────────── */
|
|
20
95
|
const s = spinner();
|
|
21
|
-
|
|
96
|
+
let latestVersions = new Map();
|
|
97
|
+
if (latest) {
|
|
22
98
|
s.start('Resolving package versions…');
|
|
23
|
-
|
|
99
|
+
latestVersions = await getPackageVersions([...packageNames]);
|
|
100
|
+
}
|
|
101
|
+
const resolveVersion = (name, listed) => latest ? (latestVersions.get(name) ?? listed) : listed;
|
|
102
|
+
/* ── Build dependency maps ───────────────────────────────── */
|
|
24
103
|
const dependencies = {};
|
|
25
104
|
const devDependencies = {};
|
|
26
105
|
devDependencies['typescript'] = resolveVersion('typescript', versions['typescript']);
|
|
27
|
-
const flags = computeFlags(frontendDirectories);
|
|
28
106
|
for (const p of defaultPlugins) {
|
|
29
107
|
dependencies[p.value] = resolveVersion(p.value, p.latestVersion);
|
|
30
108
|
}
|
|
@@ -91,13 +169,13 @@ export const createPackageJson = ({ projectName, authOption, plugins, databaseEn
|
|
|
91
169
|
s.stop(green('Package versions resolved'));
|
|
92
170
|
const scripts = {
|
|
93
171
|
dev: 'absolutejs dev',
|
|
94
|
-
format: `prettier --write "./**/*.{js,ts,css,json,mjs,md${flags.requiresReact ? ',jsx,tsx' : ''}${flags.requiresSvelte ? ',svelte' : ''}${flags.requiresVue ? ',vue' : ''}${flags.requiresHtml || flags.requiresHtmx ? ',html' : ''}}"`,
|
|
95
|
-
lint: 'eslint
|
|
172
|
+
format: `absolutejs prettier --write "./**/*.{js,ts,css,json,mjs,md${flags.requiresReact ? ',jsx,tsx' : ''}${flags.requiresSvelte ? ',svelte' : ''}${flags.requiresVue ? ',vue' : ''}${flags.requiresHtml || flags.requiresHtmx ? ',html' : ''}}"`,
|
|
173
|
+
lint: 'absolutejs eslint',
|
|
96
174
|
test: 'echo "Error: no test specified" && exit 1',
|
|
97
175
|
typecheck: 'bun run tsc --noEmit'
|
|
98
176
|
};
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
177
|
+
const isLocalDb = isLocal;
|
|
178
|
+
if (isLocalDb &&
|
|
101
179
|
databaseEngine !== undefined &&
|
|
102
180
|
databaseEngine !== 'none' &&
|
|
103
181
|
databaseEngine !== 'sqlite') {
|
|
@@ -111,29 +189,29 @@ export const createPackageJson = ({ projectName, authOption, plugins, databaseEn
|
|
|
111
189
|
scripts[`predb:${databaseEngine}`] = 'bun db:up';
|
|
112
190
|
scripts[`postdb:${databaseEngine}`] = 'bun db:down';
|
|
113
191
|
}
|
|
114
|
-
if (
|
|
192
|
+
if (isLocalDb &&
|
|
115
193
|
(databaseEngine === 'mysql' || databaseEngine === 'mariadb') &&
|
|
116
194
|
orm === 'drizzle') {
|
|
117
195
|
dependencies['mysql2'] = resolveVersion('mysql2', versions['mysql2']);
|
|
118
196
|
}
|
|
119
|
-
if (
|
|
197
|
+
if (isLocalDb && databaseEngine === 'singlestore') {
|
|
120
198
|
dependencies['mysql2'] = resolveVersion('mysql2', versions['mysql2']);
|
|
121
199
|
}
|
|
122
200
|
if (databaseEngine === 'postgresql' && databaseHost === 'planetscale') {
|
|
123
201
|
dependencies['pg'] = resolveVersion('pg', versions['pg']);
|
|
124
202
|
devDependencies['@types/pg'] = resolveVersion('@types/pg', versions['@types/pg']);
|
|
125
203
|
}
|
|
126
|
-
if (
|
|
204
|
+
if (isLocalDb && databaseEngine === 'mssql') {
|
|
127
205
|
dependencies['mssql'] = resolveVersion('mssql', versions['mssql']);
|
|
128
206
|
devDependencies['@types/mssql'] = resolveVersion('@types/mssql', versions['@types/mssql']);
|
|
129
207
|
}
|
|
130
|
-
if (
|
|
208
|
+
if (isLocalDb && databaseEngine === 'gel') {
|
|
131
209
|
dependencies['gel'] = resolveVersion('gel', versions['gel']);
|
|
132
210
|
}
|
|
133
211
|
if (databaseEngine === 'mongodb') {
|
|
134
212
|
dependencies['mongodb'] = resolveVersion('mongodb', versions['mongodb']);
|
|
135
213
|
}
|
|
136
|
-
if (
|
|
214
|
+
if (isLocalDb && databaseEngine === 'sqlite') {
|
|
137
215
|
scripts['db:sqlite'] = 'sqlite3 db/database.sqlite';
|
|
138
216
|
scripts['db:init'] = 'sqlite3 db/database.sqlite < db/init.sql';
|
|
139
217
|
}
|
|
@@ -3,12 +3,11 @@ import { join } from 'path';
|
|
|
3
3
|
import { isDrizzleDialect } from '../../typeGuards';
|
|
4
4
|
export const generateImportsBlock = ({ backendDirectory, deps, flags, orm, authOption, databaseEngine, databaseHost, frontendDirectories }) => {
|
|
5
5
|
const rawImports = [];
|
|
6
|
-
const pushHandler = (cond, name) => cond &&
|
|
7
|
-
rawImports.push(`import { ${name} } from '@absolutejs/absolute'`);
|
|
6
|
+
const pushHandler = (cond, name, pkg = '@absolutejs/absolute') => cond && rawImports.push(`import { ${name} } from '${pkg}'`);
|
|
8
7
|
pushHandler(flags.requiresHtml, 'handleHTMLPageRequest');
|
|
9
8
|
pushHandler(flags.requiresReact, 'handleReactPageRequest');
|
|
10
|
-
pushHandler(flags.requiresSvelte, 'handleSveltePageRequest');
|
|
11
|
-
pushHandler(flags.requiresVue, 'handleVuePageRequest');
|
|
9
|
+
pushHandler(flags.requiresSvelte, 'handleSveltePageRequest', '@absolutejs/absolute/svelte');
|
|
10
|
+
pushHandler(flags.requiresVue, 'handleVuePageRequest', '@absolutejs/absolute/vue');
|
|
12
11
|
pushHandler(flags.requiresVue, 'generateHeadElement');
|
|
13
12
|
pushHandler(flags.requiresHtmx, 'handleHTMXPageRequest');
|
|
14
13
|
const nonFrameworkOnly = (flags.requiresHtml || flags.requiresHtmx) &&
|
|
@@ -3,6 +3,7 @@ type ScaffoldFrontendsProps = Pick<CreateConfiguration, 'useHTMLScripts' | 'fron
|
|
|
3
3
|
frontendDirectory: string;
|
|
4
4
|
templatesDirectory: string;
|
|
5
5
|
projectAssetsDirectory: string;
|
|
6
|
+
typesDirectory: string;
|
|
6
7
|
};
|
|
7
|
-
export declare const scaffoldFrontends: ({ frontendDirectory, assetsDirectory, absProviders, authOption, templatesDirectory, projectAssetsDirectory, useHTMLScripts, useTailwind, frontendDirectories, frontends }: ScaffoldFrontendsProps) => void;
|
|
8
|
+
export declare const scaffoldFrontends: ({ frontendDirectory, assetsDirectory, absProviders, authOption, templatesDirectory, projectAssetsDirectory, typesDirectory, useHTMLScripts, useTailwind, frontendDirectories, frontends }: ScaffoldFrontendsProps) => void;
|
|
8
9
|
export {};
|
|
@@ -5,7 +5,7 @@ import { scaffoldHTMX } from '../htmx/scaffoldHTMX';
|
|
|
5
5
|
import { scaffoldReact } from '../react/scaffoldReact';
|
|
6
6
|
import { scaffoldSvelte } from '../svelte/scaffoldSvelte';
|
|
7
7
|
import { scaffoldVue } from '../vue/scaffoldVue';
|
|
8
|
-
export const scaffoldFrontends = ({ frontendDirectory, assetsDirectory, absProviders, authOption, templatesDirectory, projectAssetsDirectory, useHTMLScripts, useTailwind, frontendDirectories, frontends }) => {
|
|
8
|
+
export const scaffoldFrontends = ({ frontendDirectory, assetsDirectory, absProviders, authOption, templatesDirectory, projectAssetsDirectory, typesDirectory, useHTMLScripts, useTailwind, frontendDirectories, frontends }) => {
|
|
9
9
|
const stylesTargetDirectory = join(frontendDirectory, 'styles');
|
|
10
10
|
cpSync(join(templatesDirectory, 'styles'), stylesTargetDirectory, {
|
|
11
11
|
recursive: true
|
|
@@ -60,6 +60,7 @@ export const scaffoldFrontends = ({ frontendDirectory, assetsDirectory, absProvi
|
|
|
60
60
|
targetDirectory,
|
|
61
61
|
templatesDirectory
|
|
62
62
|
});
|
|
63
|
+
copyFileSync(join(templatesDirectory, 'types', 'vue-shim.d.ts'), join(typesDirectory, 'vue-shim.d.ts'));
|
|
63
64
|
break;
|
|
64
65
|
case 'angular':
|
|
65
66
|
console.warn('Angular is not yet supported. Refer to the documentation for more information.');
|
package/dist/scaffold.js
CHANGED
|
@@ -26,7 +26,7 @@ export const scaffold = async ({ response: { projectName, codeQualityTool, initi
|
|
|
26
26
|
tailwind,
|
|
27
27
|
templatesDirectory
|
|
28
28
|
});
|
|
29
|
-
createPackageJson({
|
|
29
|
+
await createPackageJson({
|
|
30
30
|
authOption,
|
|
31
31
|
codeQualityTool,
|
|
32
32
|
databaseEngine,
|
|
@@ -77,6 +77,7 @@ export const scaffold = async ({ response: { projectName, codeQualityTool, initi
|
|
|
77
77
|
frontends,
|
|
78
78
|
projectAssetsDirectory,
|
|
79
79
|
templatesDirectory,
|
|
80
|
+
typesDirectory,
|
|
80
81
|
useHTMLScripts,
|
|
81
82
|
useTailwind
|
|
82
83
|
});
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
4
|
|
|
5
5
|
/* Projects */
|
|
6
|
-
|
|
6
|
+
"incremental": true,
|
|
7
|
+
"tsBuildInfoFile": ".absolutejs/tsconfig.tsbuildinfo",
|
|
7
8
|
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
9
|
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
10
|
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
@@ -85,12 +85,6 @@
|
|
|
85
85
|
"skipLibCheck": true /* Type Checking */,
|
|
86
86
|
/* Skip type checking all .d.ts files. */ "strict": true /* Visit https://aka.ms/tsconfig to read more about this file */,
|
|
87
87
|
/* Enable all strict type-checking options. */ /* Projects */
|
|
88
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
89
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
90
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
91
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
92
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
93
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
94
88
|
/* Language and Environment */
|
|
95
89
|
"target": "ESNext"
|
|
96
90
|
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ /* Skip type checking all .d.ts files. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getPackageVersions: (packageNames: string[]) => Promise<Map<string, string>>;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export const getPackageVersions = async (packageNames) => {
|
|
2
|
+
const results = await Promise.all(packageNames.map(async (name) => {
|
|
3
|
+
try {
|
|
4
|
+
const res = await fetch(`https://registry.npmjs.org/${name}/latest`);
|
|
5
|
+
const data = (await res.json());
|
|
6
|
+
return [name, data.version];
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return [name, null];
|
|
10
|
+
}
|
|
11
|
+
}));
|
|
12
|
+
const map = new Map();
|
|
13
|
+
for (const [name, version] of results) {
|
|
14
|
+
if (version)
|
|
15
|
+
map.set(name, version);
|
|
11
16
|
}
|
|
17
|
+
return map;
|
|
12
18
|
};
|
package/dist/versions.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Run `bun run check-versions` to compare against latest npm versions.
|
|
5
5
|
*/
|
|
6
6
|
export declare const versions: {
|
|
7
|
-
readonly '@absolutejs/absolute': "0.
|
|
7
|
+
readonly '@absolutejs/absolute': "0.16.9";
|
|
8
8
|
readonly '@absolutejs/auth': "0.22.0";
|
|
9
9
|
readonly '@elysiajs/static': "1.4.7";
|
|
10
10
|
readonly elysia: "1.4.22";
|
package/dist/versions.js
CHANGED
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"description": "A CLI tool to create a new AbsoluteJS project",
|
|
12
12
|
"devDependencies": {
|
|
13
|
+
"@absolutejs/absolute": "0.16.9",
|
|
13
14
|
"@stylistic/eslint-plugin-ts": "4.2.0",
|
|
14
15
|
"@types/bun": "1.3.8",
|
|
15
16
|
"@types/react": "19.2.13",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"typecheck": "bun run tsc --noEmit"
|
|
50
51
|
},
|
|
51
52
|
"type": "module",
|
|
52
|
-
"version": "0.10.
|
|
53
|
+
"version": "0.10.2"
|
|
53
54
|
}
|