@gjsify/create-app 0.1.0
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/README.md +15 -0
- package/lib/create.d.ts +1 -0
- package/lib/create.js +33 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +18 -0
- package/package.json +33 -0
- package/templates/package.json.tmpl +20 -0
- package/templates/src/index.ts.tmpl +23 -0
- package/templates/tsconfig.json.tmpl +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @gjsify/create-app
|
|
2
|
+
|
|
3
|
+
Scaffolding tool for creating new Gjsify projects.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm create @gjsify/app my-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
package/lib/create.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createProject(projectName: string): Promise<void>;
|
package/lib/create.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, cpSync } from 'node:fs';
|
|
2
|
+
import { resolve, join, dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
export async function createProject(projectName) {
|
|
6
|
+
const targetDir = resolve(process.cwd(), projectName);
|
|
7
|
+
if (existsSync(targetDir)) {
|
|
8
|
+
console.error(`Error: Directory "${projectName}" already exists.`);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
console.log(`Creating new Gjsify project in ${targetDir}...`);
|
|
12
|
+
// Create directory structure
|
|
13
|
+
mkdirSync(join(targetDir, 'src'), { recursive: true });
|
|
14
|
+
// Copy template files
|
|
15
|
+
const templatesDir = resolve(__dirname, '..', 'templates');
|
|
16
|
+
// Generate package.json from template
|
|
17
|
+
const packageJsonTemplate = readFileSync(join(templatesDir, 'package.json.tmpl'), 'utf-8');
|
|
18
|
+
const packageJson = packageJsonTemplate.replace(/\{\{projectName\}\}/g, projectName);
|
|
19
|
+
writeFileSync(join(targetDir, 'package.json'), packageJson);
|
|
20
|
+
// Copy tsconfig.json
|
|
21
|
+
cpSync(join(templatesDir, 'tsconfig.json.tmpl'), join(targetDir, 'tsconfig.json'));
|
|
22
|
+
// Copy src/index.ts
|
|
23
|
+
cpSync(join(templatesDir, 'src', 'index.ts.tmpl'), join(targetDir, 'src', 'index.ts'));
|
|
24
|
+
console.log('');
|
|
25
|
+
console.log('Project created successfully!');
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log('Next steps:');
|
|
28
|
+
console.log(` cd ${projectName}`);
|
|
29
|
+
console.log(' npm install');
|
|
30
|
+
console.log(' npm run build');
|
|
31
|
+
console.log(' npm start');
|
|
32
|
+
console.log('');
|
|
33
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import yargs from 'yargs';
|
|
3
|
+
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import { createProject } from './create.js';
|
|
5
|
+
void yargs(hideBin(process.argv))
|
|
6
|
+
.scriptName('@gjsify/create-app')
|
|
7
|
+
.usage('$0 [project-name]', 'Create a new Gjsify project', (yargs) => {
|
|
8
|
+
return yargs.positional('project-name', {
|
|
9
|
+
describe: 'Name of the project directory to create',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: 'my-gjs-app'
|
|
12
|
+
});
|
|
13
|
+
}, async (argv) => {
|
|
14
|
+
const projectName = argv['project-name'];
|
|
15
|
+
await createProject(projectName);
|
|
16
|
+
})
|
|
17
|
+
.help()
|
|
18
|
+
.argv;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gjsify/create-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Create a new Gjsify project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"bin": "./lib/index.js",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clear": "rm -rf lib tsconfig.tsbuildinfo || exit 0",
|
|
10
|
+
"check": "tsc --noEmit",
|
|
11
|
+
"build": "tsc && chmod +x ./lib/index.js",
|
|
12
|
+
"test": "echo 'nothing to do'"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"gjs",
|
|
16
|
+
"gjsify",
|
|
17
|
+
"create",
|
|
18
|
+
"scaffold",
|
|
19
|
+
"gnome"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"lib",
|
|
23
|
+
"templates"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"yargs": "^18.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^25.5.0",
|
|
30
|
+
"@types/yargs": "^17.0.35",
|
|
31
|
+
"typescript": "^6.0.2"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "gjsify build src/index.ts --outfile dist/index.js",
|
|
8
|
+
"start": "gjsify run dist/index.js",
|
|
9
|
+
"dev": "gjsify build src/index.ts --outfile dist/index.js && gjsify run dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@gjsify/cli": "^0.1.0",
|
|
13
|
+
"@types/node": "^25.5.0",
|
|
14
|
+
"typescript": "^6.0.2"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@girs/gtk-4.0": "^4.22.1-4.0.0-beta.42",
|
|
18
|
+
"@gjsify/node-globals": "^0.1.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Gtk from 'gi://Gtk?version=4.0'
|
|
2
|
+
|
|
3
|
+
const app = new Gtk.Application({
|
|
4
|
+
applicationId: 'org.gjsify.example',
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
app.connect('activate', () => {
|
|
8
|
+
const window = new Gtk.ApplicationWindow({
|
|
9
|
+
application: app,
|
|
10
|
+
title: 'Hello from Gjsify',
|
|
11
|
+
defaultWidth: 400,
|
|
12
|
+
defaultHeight: 300,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const label = new Gtk.Label({
|
|
16
|
+
label: 'Hello from Gjsify!',
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
window.setChild(label)
|
|
20
|
+
window.present()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
app.run([])
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "NodeNext",
|
|
7
|
+
"moduleResolution": "NodeNext",
|
|
8
|
+
"types": ["node", "@girs/gtk-4.0"],
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|