lapikit 0.0.0-insiders.bd609af → 0.0.0-insiders.bf30361
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/bin/configuration.js +22 -19
- package/bin/index.js +4 -4
- package/bin/presets.js +7 -5
- package/bin/prompts.js +5 -6
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -3
- package/package.json +1 -1
package/bin/configuration.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { terminal } from './helper.js';
|
|
4
5
|
import presets from './presets.js';
|
|
5
6
|
|
|
6
7
|
async function findReferenceFile(projectPath) {
|
|
@@ -9,7 +10,8 @@ async function findReferenceFile(projectPath) {
|
|
|
9
10
|
try {
|
|
10
11
|
await fs.access(routesPath);
|
|
11
12
|
} catch {
|
|
12
|
-
|
|
13
|
+
terminal('error', `Lapikit cannot find the routes/ directory.`);
|
|
14
|
+
// throw new Error('Lapikit cannot find the routes/ directory.');
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const layoutFile = path.join(routesPath, '+layout.svelte');
|
|
@@ -65,7 +67,7 @@ async function addImportToReferenceFile(targetFile, referenceFile) {
|
|
|
65
67
|
const importStatement = `import "${relativePath.startsWith('.') ? relativePath : './' + relativePath}";\n`;
|
|
66
68
|
|
|
67
69
|
if (content.includes(`import "${relativePath}"`)) {
|
|
68
|
-
|
|
70
|
+
terminal('info', `Import statement already exists in ${referenceFile}`);
|
|
69
71
|
return;
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -103,9 +105,9 @@ async function addImportToReferenceFile(targetFile, referenceFile) {
|
|
|
103
105
|
const newContent = lines.join('\n');
|
|
104
106
|
|
|
105
107
|
await fs.writeFile(referenceFile, newContent);
|
|
106
|
-
|
|
108
|
+
terminal('info', `Import has been added to ${referenceFile}`);
|
|
107
109
|
} catch (error) {
|
|
108
|
-
|
|
110
|
+
terminal('error', `Error adding import: ${error.message}`);
|
|
109
111
|
throw error;
|
|
110
112
|
}
|
|
111
113
|
}
|
|
@@ -138,7 +140,7 @@ async function addLapikitToViteConfig(viteConfigFile) {
|
|
|
138
140
|
|
|
139
141
|
// Check if lapikit import already exists
|
|
140
142
|
if (content.includes(lapikitImport) || content.includes(`from 'lapikit/vite'`)) {
|
|
141
|
-
|
|
143
|
+
terminal('info', `Lapikit import already exists in ${viteConfigFile}`);
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -231,20 +233,19 @@ async function addLapikitToViteConfig(viteConfigFile) {
|
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
if (!pluginAdded) {
|
|
234
|
-
|
|
236
|
+
terminal('warn', `Could not find sveltekit() in plugins array to add lapikit() after it`);
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
const newContent = lines.join('\n');
|
|
238
240
|
await fs.writeFile(viteConfigFile, newContent);
|
|
239
|
-
|
|
241
|
+
terminal('info', `Lapikit import and plugin added to ${viteConfigFile}`);
|
|
240
242
|
} catch (error) {
|
|
241
|
-
|
|
243
|
+
terminal('error', `Error adding lapikit to vite config: ${error.message}`);
|
|
242
244
|
throw error;
|
|
243
245
|
}
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
export async function initConfiguration(options) {
|
|
247
|
-
console.log('initConfiguration called with:', options);
|
|
248
249
|
const { typescript, pathConfig, formatCSS } = options;
|
|
249
250
|
const ext = typescript ? 'ts' : 'js';
|
|
250
251
|
const targetDir = path.resolve(process.cwd(), pathConfig);
|
|
@@ -253,30 +254,32 @@ export async function initConfiguration(options) {
|
|
|
253
254
|
await fs.mkdir(targetDir, { recursive: true });
|
|
254
255
|
|
|
255
256
|
let fileCreated = false;
|
|
257
|
+
|
|
258
|
+
// Create Lapikit config
|
|
256
259
|
try {
|
|
257
|
-
console.log(`Trying to access ${targetFile}`);
|
|
258
260
|
await fs.access(targetFile);
|
|
259
|
-
|
|
261
|
+
terminal('info', `File ${targetFile} already exists.`);
|
|
260
262
|
} catch {
|
|
261
|
-
|
|
263
|
+
terminal('info', `Creating file: ${targetFile}`);
|
|
262
264
|
const content = presets({
|
|
263
|
-
|
|
265
|
+
adapterCSS: formatCSS
|
|
264
266
|
});
|
|
265
267
|
await fs.writeFile(targetFile, content);
|
|
266
|
-
|
|
268
|
+
terminal('info', `File created: ${targetFile}`);
|
|
267
269
|
fileCreated = true;
|
|
268
270
|
}
|
|
269
271
|
|
|
272
|
+
// Add Import Lapikit plugin
|
|
270
273
|
try {
|
|
271
274
|
const referenceFile = await findReferenceFile(process.cwd());
|
|
272
275
|
await addImportToReferenceFile(targetFile, referenceFile);
|
|
273
276
|
} catch (error) {
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
terminal('error', `Error adding import: ${error.message}`);
|
|
278
|
+
|
|
276
279
|
if (fileCreated) {
|
|
277
280
|
try {
|
|
278
281
|
await fs.unlink(targetFile);
|
|
279
|
-
|
|
282
|
+
terminal('info', `File ${targetFile} deleted due to error.`);
|
|
280
283
|
} catch {
|
|
281
284
|
// Ignore deletion error
|
|
282
285
|
}
|
|
@@ -289,7 +292,7 @@ export async function initConfiguration(options) {
|
|
|
289
292
|
const viteConfigFile = await findViteConfigFile(process.cwd(), typescript);
|
|
290
293
|
await addLapikitToViteConfig(viteConfigFile);
|
|
291
294
|
} catch (error) {
|
|
292
|
-
|
|
293
|
-
|
|
295
|
+
terminal('warn', `Warning: Could not update vite.config file: ${error.message}`);
|
|
296
|
+
terminal('error', `Error adding lapikit to vite config: ${error.message}`);
|
|
294
297
|
}
|
|
295
298
|
}
|
package/bin/index.js
CHANGED
|
@@ -30,12 +30,12 @@ async function run() {
|
|
|
30
30
|
|
|
31
31
|
run()
|
|
32
32
|
.then(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
terminal('none', `\n\n\n\nWebsite: https://lapikit.dev`);
|
|
34
|
+
terminal('none', `Github: https://github.com/nycolaide/lapikit`);
|
|
35
|
+
terminal('none', `Support the developement: https://buymeacoffee.com/nycolaide`);
|
|
36
36
|
process.exit(0);
|
|
37
37
|
})
|
|
38
38
|
.catch((error) => {
|
|
39
|
-
|
|
39
|
+
terminal('error', `Error: ${error}`);
|
|
40
40
|
process.exit(1);
|
|
41
41
|
});
|
package/bin/presets.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function presets({
|
|
1
|
+
function presets({ adapterCSS }) {
|
|
2
2
|
let content = '';
|
|
3
3
|
|
|
4
4
|
content += `/**\n`;
|
|
@@ -6,16 +6,18 @@ function presets({ classic }) {
|
|
|
6
6
|
content += `\t* Library documentation: https://lapikit.dev\n`;
|
|
7
7
|
content += ` */\n\n`;
|
|
8
8
|
|
|
9
|
-
if (
|
|
10
|
-
content += `//
|
|
9
|
+
if (adapterCSS === 'css') {
|
|
10
|
+
content += `// Styles\n`;
|
|
11
11
|
content += `import 'lapikit/css';\n\n`;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
content += `// Composables\n`;
|
|
15
|
-
content += `import
|
|
15
|
+
content += `import createLapikit from 'lapikit';\n\n`;
|
|
16
16
|
|
|
17
17
|
content += `// https://lapikit.dev/docs/getting-started\n`;
|
|
18
|
-
content += `export default
|
|
18
|
+
content += `export default createLapikit({\n`;
|
|
19
|
+
content += `\tadapterCSS: "${adapterCSS}",\n`;
|
|
20
|
+
content += `\n});`;
|
|
19
21
|
|
|
20
22
|
return content;
|
|
21
23
|
}
|
package/bin/prompts.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import prompts from 'prompts';
|
|
3
|
+
import { terminal } from './helper.js';
|
|
3
4
|
|
|
4
5
|
export async function initPrompts() {
|
|
5
6
|
const { confirm } = await prompts({
|
|
6
7
|
type: 'toggle',
|
|
7
8
|
name: 'confirm',
|
|
8
|
-
message: '
|
|
9
|
+
message: 'Launch install Lapikit on your project?',
|
|
9
10
|
initial: true,
|
|
10
11
|
active: 'Yes',
|
|
11
12
|
inactive: 'No'
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
if (!confirm) {
|
|
15
|
-
|
|
16
|
+
terminal('warn', `installation canceled.`);
|
|
16
17
|
process.exit(0);
|
|
17
18
|
}
|
|
18
19
|
// temps with legacy and new process install
|
|
@@ -70,7 +71,7 @@ export async function initPrompts() {
|
|
|
70
71
|
name: 'formatCSS',
|
|
71
72
|
message: 'What is your CSS format used on your app?',
|
|
72
73
|
choices: [
|
|
73
|
-
{ title: 'Basic (classic import)', value: '
|
|
74
|
+
{ title: 'Basic (classic import)', value: 'css' },
|
|
74
75
|
{
|
|
75
76
|
title: 'TailwindCSS (v4)',
|
|
76
77
|
value: 'tailwind-v4'
|
|
@@ -82,7 +83,7 @@ export async function initPrompts() {
|
|
|
82
83
|
]
|
|
83
84
|
},
|
|
84
85
|
{
|
|
85
|
-
type: (prev) => (prev !== '
|
|
86
|
+
type: (prev) => (prev !== 'css' ? 'text' : null),
|
|
86
87
|
name: 'pathCSS',
|
|
87
88
|
message: 'Where would you like to import the lapikit CSS files?',
|
|
88
89
|
initial: 'src/app.css',
|
|
@@ -91,8 +92,6 @@ export async function initPrompts() {
|
|
|
91
92
|
}
|
|
92
93
|
]);
|
|
93
94
|
|
|
94
|
-
console.log('response config', settings);
|
|
95
|
-
|
|
96
95
|
return {
|
|
97
96
|
...settings,
|
|
98
97
|
env: 'experimental'
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
console.log('
|
|
1
|
+
function createLapikit(lapikit) {
|
|
2
|
+
console.log('Creating a new Lapikit instance...');
|
|
3
|
+
console.log('Options loaded:', lapikit);
|
|
4
4
|
}
|
|
5
|
+
export default createLapikit;
|