The Wayback Machine - https://web.archive.org/web/20231227110145/https://github.com/angular/angular-cli/issues/15335
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

schematics API reference #15335

Closed
xxyyzz2050 opened this issue Aug 14, 2019 · 12 comments
Closed

schematics API reference #15335

xxyyzz2050 opened this issue Aug 14, 2019 · 12 comments
Labels
area: devkit/schematics area: docs Related to the documentation feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature
Milestone

Comments

@xxyyzz2050
Copy link

I see that there is a guide for Schematics, but I don't see any reference for Schematics API, so we can learn all about all Schematics functions.

@alan-agius4 alan-agius4 added area: docs Related to the documentation feature Issue that requests a new feature labels Aug 15, 2019
@KingDarBoja
Copy link

Was looking for the same stuff on the official documentation, hopefully the Angular team will provide it soon (I hope). +1

@xxyyzz2050
Copy link
Author

any news?

@alan-agius4

@alan-agius4
Copy link
Collaborator

There is no ETA for this yet.

@ngbot ngbot bot added this to the Backlog milestone Jun 8, 2020
@KingDarBoja
Copy link

Is there anything that can be done by the community to improve the docs? There are few tutorials with some API functions explained (like this one) so maybe extracting the description and using the type definitions would help with this task.

@d-koppenhagen
Copy link

d-koppenhagen commented Jul 19, 2020

Hey, I am planning to write a blog post about some very common API Util functions you can use. Unfortunately those utils aren't documented yet but can basically be found here: https://github.com/angular/angular-cli/tree/master/packages/schematics/angular/utility

You can import the function from @schematics/angular/utility/file.

So for example handling changes on package.json will work like this:

import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics/';
import {
  NodeDependency,
  NodeDependencyType
  getPackageJsonDependency,
  addPackageJsonDependency,
  removePackageJsonDependency,
} from '@schematics/angular/utility/dependencies';

export function playground(_options: any): Rule {
  return (tree: Tree, _context: SchematicContext) => {
    const dep: NodeDependency = {
      type: NodeDependencyType.Dev,
      name: 'my-package',
      version: '~0.3.4-beta.1',
      overwrite: true,
    };

    addPackageJsonDependency(tree, dep);
    console.log(getPackageJsonDependency(tree, 'my-package'))
    // { type: 'dependencies', name: 'typescript', version: '~3.9.2' }

    removePackageJsonDependency(tree, 'my-package');
    console.log(getPackageJsonDependency(tree, 'my-package'))
    // null

    return tree;
  };
}

I think it would be really helpful I the docs for the utils will be generated directly from the source in the future.
Probably a separate docs site would be great such as schematics.angular.io or something similar

@alan-agius4
Copy link
Collaborator

@d-koppenhagen, those utils are not considered as part of the public API and might break without warning in any release.

There are plans to provide some utilities via public API but this is still in planning stages.

@d-koppenhagen
Copy link

Okay that's good to know. Yes it would be really great as I've seen a lots of people authoring schematics with almost the same util functions which is I think not the best.

@d-koppenhagen
Copy link

@alan-agius4 is there a way I / others can help bringing this to a next level? I would really like to help and contribute but don't know where to start.

@alan-agius4
Copy link
Collaborator

Hi @d-koppenhagen, thanks for your interest in helping with this.I do think however that this needs to be taken by someone on the team. The reason being is that entire API surface needs to be reviewed and decide which parts of it should be kept, modified or deprecated.

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Feb 1, 2022
@angular-robot angular-robot bot added feature: under consideration Feature request for which voting has completed and the request is now under consideration and removed feature: votes required Feature request which is currently still in the voting phase labels Feb 10, 2022
@dgp1130
Copy link
Collaborator

dgp1130 commented Apr 14, 2022

Agreed that schematics documentation is quite lacking right now and we are hoping to improve it. We have a near-future project adding common utilities to schematics and this would be a good opportunity to refactor the documentation and provide more comprehensive information. There will also be some non-trivial infrastructure requirements to generate API documentation from JSDoc comments and plumb them through to angular.io. This is already done for other Angular APIs, but it is more complicated for the CLI since we live in a different GitHub repository than angular.io.

This work is being tracked separately, so I don't think there's anything immediately actionable in this issue. I'm going to close it for the time being, but we hoping to improve this area in the near-future.

@dgp1130 dgp1130 closed this as completed Apr 14, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/schematics area: docs Related to the documentation feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature
5 participants