Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement react-feature generator #35

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/preset-anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Name: anchor-application (aliases: application, preset)
Options:
--name Name of the application [string]
--template The template to use [string] [choices: "counter",
"hello-world"] [default:
"counter"]
"hello-world", "none"]
[default: "none"]
--skipFormat Skip formatting files [boolean]
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ exports[`anchor-application generator should generate app with "counter" templat
"import { IDL as CounterIDL } from '../target/types/counter';",
"// Re-export the generated IDL and type",
"export { Counter, CounterIDL };",
"export type CounterProgram = Program<Counter>;",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_PROGRAM_ID = new PublicKey(",
"'CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg'",
Expand Down Expand Up @@ -1215,7 +1214,6 @@ exports[`anchor-application generator should generate app with "hello-world" tem
"import { IDL as HelloWorldIDL } from '../target/types/hello_world';",
"// Re-export the generated IDL and type",
"export { HelloWorld, HelloWorldIDL };",
"export type HelloWorldProgram = Program<HelloWorld>;",
],
"isBinary": false,
"path": "anchor-app/src/hello-world-exports.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export async function anchorApplicationGenerator(tree: Tree, rawOptions: AnchorA
directory: project.root,
skipUpdateIndexTs: true,
})
await anchorTemplateGenerator(tree, {
projectName: options.name,
name: options.template,
template: options.template,
directory: project.root,
})
if (options.template !== 'none') {
await anchorTemplateGenerator(tree, {
projectName: options.name,
name: options.template,
template: options.template,
directory: project.root,
})
}
anchorApplicationDependencies(tree)
anchorApplicationIgnoreFiles(tree, project.sourceRoot.replace('/src', ''))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export interface AnchorApplicationSchema {
/**
* The template to use
*/
template?: "counter" | "hello-world";
template?: "counter" | "hello-world" | "none";
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
},
"template": {
"type": "string",
"enum": ["counter", "hello-world"],
"enum": ["counter", "hello-world", "none"],
"description": "The template to use",
"default": "counter"
"default": "none"
}
},
"required": ["name"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ exports[`anchor-template generator should be able to generate two templates side
"import { IDL as CounterOneIDL } from '../target/types/counter_one';",
"// Re-export the generated IDL and type",
"export { CounterOne, CounterOneIDL };",
"export type CounterOneProgram = Program<CounterOne>;",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_ONE_PROGRAM_ID = new PublicKey('CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg')",
"// This is a helper function to get the program ID for the CounterOne program depending on the cluster.",
Expand All @@ -275,7 +274,6 @@ exports[`anchor-template generator should be able to generate two templates side
"import { IDL as CounterTwoIDL } from '../target/types/counter_two';",
"// Re-export the generated IDL and type",
"export { CounterTwo, CounterTwoIDL };",
"export type CounterTwoProgram = Program<CounterTwo>;",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_TWO_PROGRAM_ID = new PublicKey('CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg')",
"// This is a helper function to get the program ID for the CounterTwo program depending on the cluster.",
Expand Down Expand Up @@ -1273,7 +1271,6 @@ exports[`anchor-template generator should generate files for counter template 1`
"import { IDL as CounterIDL } from '../target/types/counter';",
"// Re-export the generated IDL and type",
"export { Counter, CounterIDL };",
"export type CounterProgram = Program<Counter>;",
"// After updating your program ID (e.g. after running \`anchor keys sync\`) update the value below.",
"export const COUNTER_PROGRAM_ID = new PublicKey('CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg')",
"// This is a helper function to get the program ID for the Counter program depending on the cluster.",
Expand Down Expand Up @@ -1786,7 +1783,6 @@ exports[`anchor-template generator should generate files for hello-world templat
"import { IDL as HelloWorldIDL } from '../target/types/hello_world';",
"// Re-export the generated IDL and type",
"export { HelloWorld, HelloWorldIDL };",
"export type HelloWorldProgram = Program<HelloWorld>;",
],
"isBinary": false,
"path": "target/src/hello-world-exports.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IDL as <%= className %>IDL } from '../target/types/<%= fileNameUndersco

// Re-export the generated IDL and type
export { <%= className %>, <%= className %>IDL };
export type <%= className %>Program = Program<<%= className %>>;

// After updating your program ID (e.g. after running `anchor keys sync`) update the value below.
export const <%= upperCaseName %>_PROGRAM_ID = new PublicKey('CounNZdmsQmWh7uVngV9FXW2dZ6zAgbJyYsvBpqbykg')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ import { IDL as <%= className %>IDL } from '../target/types/<%= fileNameUndersco

// Re-export the generated IDL and type
export { <%= className %>, <%= className %>IDL };
export type <%= className %>Program = Program<<%= className %>>;
2 changes: 2 additions & 0 deletions packages/preset-anchor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './generators/anchor-application/anchor-application-generator'
export * from './generators/anchor-application/anchor-application-schema'
export * from './generators/anchor-template/anchor-template-generator'
export * from './generators/anchor-template/anchor-template-schema'
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`common-template generator should generate files for { template: 'licens
"LICENSE": {
"content": [
"MIT License",
"Copyright (c) 2023 test",
"Copyright (c) 2024 test",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and associated documentation files (the "Software"), to deal",
"in the Software without restriction, including without limitation the rights",
Expand Down Expand Up @@ -33,7 +33,7 @@ exports[`common-template generator should generate files for { template: 'licens
"LICENSE": {
"content": [
"MIT License",
"Copyright (c) 2023 test",
"Copyright (c) 2024 test",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and associated documentation files (the "Software"), to deal",
"in the Software without restriction, including without limitation the rights",
Expand Down Expand Up @@ -61,7 +61,7 @@ exports[`common-template generator should generate files for { template: 'licens
"LICENSE": {
"content": [
"MIT License",
"Copyright (c) 2023 test",
"Copyright (c) 2024 test",
"Permission is hereby granted, free of charge, to any person obtaining a copy",
"of this software and associated documentation files (the "Software"), to deal",
"in the Software without restriction, including without limitation the rights",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'path'
import { genericSubstitutions } from '../../utils/generic-substitutions'
import { CommonTemplateSchema } from './common-template-schema'

export async function commonTemplateGenerator(tree: Tree, options: CommonTemplateSchema, templatePath: string = '') {
export async function commonTemplateGenerator(tree: Tree, options: CommonTemplateSchema, templatePath = '') {
const substitutions = genericSubstitutions({
anchor: options.anchor,
anchorName: options.anchorName,
Expand Down
Loading
Loading