Coder Social home page Coder Social logo

Comments (12)

gparlakov avatar gparlakov commented on May 26, 2024 1

POC custom template

@JarvisJ I just published a POC for custom template* - [email protected]
Please check it out. I'd appreciate feedback.

How to use:

npm i scuri@next
Windows path follows - turn the slashes if mac/linux
ng g scuri:spec --name .\src\app\app.component.ts --classTemplate .\src\template\my.tmpl

the my.tmpl file is the custom template* and

*custom class template - creates a spec for a class e.g. export class MyComponent{ ... and not export function myFunction() {...

from scuri.

gparlakov avatar gparlakov commented on May 26, 2024 1

from scuri.

gparlakov avatar gparlakov commented on May 26, 2024 1

@JarvisJ 1.1.0-rc.1 is now live with support for config file. Care to take it for a spin?

from scuri.

gparlakov avatar gparlakov commented on May 26, 2024 1

Do you want to test it with SCuri code? Well there is a way. SCuri code keeps dependencies in a shared folder (maintained by VS Code) so here's how to locate that folder on a machine and install scuri@next version

image

@JarvisJ FYI

from scuri.

JarvisJ avatar JarvisJ commented on May 26, 2024

I'd like to be able to provide a custom spec template via a config option. For people/projects who want specific boilerplate, this would be very useful.

Edit - poking around angular-schematics and the scuri code a bit, I see this isn't necessarily as straightforward as I would've hoped. Maybe custom templates is more of a feature request for the schematics project.

from scuri.

gparlakov avatar gparlakov commented on May 26, 2024

@JarvisJ thanks for the feedback. I intend to look into that. Will let you know .

from scuri.

JarvisJ avatar JarvisJ commented on May 26, 2024

Awesome! I tried out 1.0.8-rc.1, and it worked as expected with my custom template. Thanks!

from scuri.

JarvisJ avatar JarvisJ commented on May 26, 2024

Works great so far! Thanks!

Edit - and to confirm, I did test specifying the template from package.json. That works as expected.

from scuri.

JarvisJ avatar JarvisJ commented on May 26, 2024

It works, using my template, with the vs-code extension. The extension still doesn't work in my multiroot workspace. I describe that issue here:

gparlakov/scuri-code#4 (comment)

from scuri.

Z-Newman avatar Z-Newman commented on May 26, 2024

Hey there. I'm picking up where Mr. JarvisJ left off (literally, same company and product), I'm finding that it would be very helpful to be able to forEach through the declaration and buildExports like we can through the params and publicMethods, there are some places where we'd like to be able to consistently override the line-by-line generation for specific classes.

from scuri.

gparlakov avatar gparlakov commented on May 26, 2024

Hey, @Z-Newman,

I think you can do that with the params property that's already exposed to the template.

From index.ts

scuri/src/spec/index.ts

Lines 173 to 184 in 969dd91

applyTemplates({
// the name of the new spec file
specFileName,
normalizedName: normalizedName,
className: name,
publicMethods,
declaration: toDeclaration(),
builderExports: toBuilderExports(),
constructorParams: toConstructorParams(),
params,
shorthand
}),

The declarations and buildExports are just representations of the (constructor) params:

scuri/src/spec/index.ts

Lines 200 to 216 in 969dd91

function toDeclaration() {
return params
.map(p =>
p.type === 'string' || p.type === 'number'
? `let ${p.name}:${p.type};`
: `const ${p.name} = autoSpy(${p.type});`
)
.join(EOL);
}
function toBuilderExports() {
return params.length > 0
? params
.map(p => p.name)
.join(',' + EOL)
.concat(',')
: '';
}

Here's an example of the template using these params

https://gist.github.com/gparlakov/f299011829e229c9d37cf0cb38506d97#file-my-tmpl-L6-L9

from scuri.

Z-Newman avatar Z-Newman commented on May 26, 2024

from scuri.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.