Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Jan 1, 2025
1 parent 606f766 commit 3bc7ac2
Show file tree
Hide file tree
Showing 58 changed files with 3,277 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ nix
examples
scripts
.github
.envrc
flake.lock
flake.nix
Taskfile.yaml
Expand All @@ -19,5 +18,4 @@ README.MD
**/bin/
**/obj/
**/node_modules/
**/env.

2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
watch_file "./nix/env.nix" "./nix/fmt.nix" "./nix/packages.nix" "./nix/shells.nix" "./nix/pre-commit.nix" "./flake.nix" "./parse.nix"
use flake
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI-CD
on:
push:
branches:
- "main"
- 'main'

env:
# Docker
Expand Down
4 changes: 2 additions & 2 deletions cyan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: CyanPrint Template to initialize Nix Flake project with optional cu
project: https://github.com/AtomiCloud/ketone.nix-init
source: https://github.com/AtomiCloud/ketone.nix-init
email: admin@atomi.cloud
tags: ["atomicloud","nix"]
tags: ['atomicloud', 'nix']
readme: cyan/README.MD
processors: ["cyan/default"]
processors: ['cyan/default']
plugins: []
Binary file modified cyan/bun.lockb
100644 → 100755
Binary file not shown.
55 changes: 55 additions & 0 deletions cyan/functions/atomi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Cyan, CyanGlob, GlobType, IDeterminism, IInquirer } from '@atomicloud/cyan-sdk';

function SimpleCopy(vars: Record<string, string | boolean>, ...files: CyanGlob[]): Cyan {
return {
plugins: [],
processors: [
{
name: 'cyan/default',
files,
config: {
vars,
parser: {
varSyntax: [
['var__', '__'],
['<%', '%>'],
],
},
},
},
],
} as Cyan;
}

export async function atomiPrompt(i: IInquirer, d: IDeterminism): Promise<Cyan> {
const runtime = await i.select('Runtime', ['Go', '.NET', 'Bun'], 'Runtime to setup with Nix');

const platform = await i.text('Platform', 'LPSM Service Tree Platform');
const service = await i.text('Service', 'LPSM Service Tree Service');

const infra = await i.confirm('Infrastructure', 'Include infrastructure binaries like helm, k3d, kubectl and docker');
const vars: Record<string, string | boolean> = { platform, service, infra };

if (runtime == 'Go') {
return SimpleCopy(vars, {
root: 'templates/go',
exclude: [],
glob: '**/*',
type: GlobType.Template,
});
} else if (runtime == '.NET') {
return SimpleCopy(vars, {
root: 'templates/dotnet',
exclude: [],
glob: '**/*',
type: GlobType.Template,
});
} else {
return SimpleCopy(vars, {
root: 'templates/bun',
exclude: [],
glob: '**/*',
type: GlobType.Template,
});
}
}
49 changes: 49 additions & 0 deletions cyan/functions/normal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Cyan, GlobType, IDeterminism, IInquirer } from '@atomicloud/cyan-sdk';

export async function normalPrompt(i: IInquirer, d: IDeterminism): Promise<Cyan> {
const vars: Record<string, string> = { description: '' };

vars.description = await i.text('Description', 'Description of this Project');

const standard = await i.confirm('Include default binaries');
const pc = await i.confirm('Include Pre-Commit Hooks');

const folder = standard ? 'templates/normal/standard' : 'templates/normal/empty';
const folderExclude = pc ? [] : ['pre-commit.nix', 'fmt.nix'];
const precommit = pc ? 'templates/normal/with-pc' : 'templates/normal/without-pc';

return {
processors: [
{
name: 'cyan/default',
files: [
{
glob: '**/*',
type: GlobType.Template,
root: 'templates/normal/common',
exclude: [],
},
{
glob: '**/*',
type: GlobType.Template,
root: folder,
exclude: folderExclude,
},
{
glob: '**/*',
type: GlobType.Template,
root: precommit,
exclude: [],
},
],
config: {
vars,
parser: {
varSyntax: [['var__', '__']],
},
},
},
],
plugins: [],
} as Cyan;
}
51 changes: 38 additions & 13 deletions cyan/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
import {StartTemplateWithLambda} from "@atomicloud/cyan-sdk";
import { Cyan, GlobType, StartTemplateWithLambda } from '@atomicloud/cyan-sdk';
import { Glob } from 'bun';
import { normalPrompt } from './functions/normal';
import { atomiPrompt } from './functions/atomi';

StartTemplateWithLambda(async (i, d) => {
return {
processors: [
{
name: "cyan/default",
files: [],
config: {},
},
],
plugins: [

],
StartTemplateWithLambda(async (i, d): Promise<Cyan> => {
const type = await i.select(
'Which type of Nix do you want to initialize?',
['Standard', 'CyanPrint Bun', 'AtomiCloud Suite'],
'For default configuration, please choose standard.',
);

if (type == 'Standard') {
return await normalPrompt(i, d);
} else if (type == 'CyanPrint Bun') {
return {
plugins: [],
processors: [
{
name: 'cyan/default',
files: [
{
root: 'templates/cyanprint-bun',
glob: '**/*',
exclude: [],
type: GlobType.Template,
},
],
config: {
vars: {},
parser: {
varSyntax: [['var__', '__']],
},
},
},
],
} as Cyan;
} else {
return await atomiPrompt(i, d);
}
});
3 changes: 2 additions & 1 deletion cyan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
"bun-types": "latest",
"oxlint": "^0.15.4"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
4 changes: 1 addition & 3 deletions cyan/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types"
]
"types": ["bun-types"]
}
}
Loading

0 comments on commit 3bc7ac2

Please sign in to comment.