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.
@@ -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
- throw new Error('Lapikit cannot find the routes/ directory.');
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
- console.log(`import has already exist ${referenceFile}`);
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
- console.log(`Import has added on ${referenceFile}`);
108
+ terminal('info', `Import has been added to ${referenceFile}`);
107
109
  } catch (error) {
108
- console.error(`Error adding import: ${error.message}`);
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
- console.log(`Lapikit import already exists in ${viteConfigFile}`);
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
- console.warn('Could not find sveltekit() in plugins array to add lapikit() after it');
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
- console.log(`Lapikit import and plugin added to ${viteConfigFile}`);
241
+ terminal('info', `Lapikit import and plugin added to ${viteConfigFile}`);
240
242
  } catch (error) {
241
- console.error(`Error adding lapikit to vite config: ${error.message}`);
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
- console.log(`File ${targetFile} already exists.`);
261
+ terminal('info', `File ${targetFile} already exists.`);
260
262
  } catch {
261
- console.log(`Creating file: ${targetFile}`);
263
+ terminal('info', `Creating file: ${targetFile}`);
262
264
  const content = presets({
263
- classic: formatCSS === 'global'
265
+ adapterCSS: formatCSS
264
266
  });
265
267
  await fs.writeFile(targetFile, content);
266
- console.log(`File created : ${targetFile}`);
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
- console.error(`Error: ${error.message}`);
275
- // If the file was just created and we can't add the import, delete it
277
+ terminal('error', `Error adding import: ${error.message}`);
278
+
276
279
  if (fileCreated) {
277
280
  try {
278
281
  await fs.unlink(targetFile);
279
- console.log(`File ${targetFile} deleted due to error.`);
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
- console.warn(`Warning: Could not update vite.config file: ${error.message}`);
293
- // This is not a critical error, so we don't throw it
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
- console.log('Website: https://lapikit.dev');
34
- console.log('Github: https://github.com/nycolaide/lapikit');
35
- console.log('Support the developement: https://buymeacoffee.com/nycolaide');
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
- console.error(`\n${red('')} ${error}\n`);
39
+ terminal('error', `Error: ${error}`);
40
40
  process.exit(1);
41
41
  });
package/bin/presets.js CHANGED
@@ -1,4 +1,4 @@
1
- function presets({ classic }) {
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 (classic) {
10
- content += `// Classic\n`;
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 { helloWorld } from 'lapikit';\n\n`;
15
+ content += `import createLapikit from 'lapikit';\n\n`;
16
16
 
17
17
  content += `// https://lapikit.dev/docs/getting-started\n`;
18
- content += `export default helloWorld();`;
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: 'Start install Lapikit on your app?',
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
- console.log(' Installation canceled. See you soon.');
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: 'global' },
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 !== 'global' ? 'text' : null),
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
@@ -1 +1,5 @@
1
- export declare function helloWorld(): void;
1
+ interface Lapikit {
2
+ adapterCSS: string;
3
+ }
4
+ declare function createLapikit(lapikit: Lapikit): void;
5
+ export default createLapikit;
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- // Reexport your entry components here
2
- export function helloWorld() {
3
- console.log('Hello world, this is lapikit!');
1
+ function createLapikit(lapikit) {
2
+ console.log('Creating a new Lapikit instance...');
3
+ console.log('Options loaded:', lapikit);
4
4
  }
5
+ export default createLapikit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.0.0-insiders.bd609af",
3
+ "version": "0.0.0-insiders.bf30361",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"