在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jvandemo/generator-angularjs-library开源软件地址(OpenSource Url):https://github.com/jvandemo/generator-angularjs-library开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):AngularJS component library generatorYeoman generator to create standalone AngularJS component libraries in seconds! In shortIf you want to create a standalone library with filters, directives, services, etc for use in your AngularJS applications, then this generator may just be what you need. The generator automatically:
Quick startMake sure you have yeoman installed: $ npm install -g yo Install the generator: $ npm install -g generator-angularjs-library Create a new project directory: $ mkdir sample-project
$ cd sample-project Run: $ yo angularjs-library Answer the questions and the generator will create the boilerplate for your library: What the generator does for youThe generator automatically:
Running the generator using library name "Your Library" will result in the following files being generated for you: .
├── .bowerrc # Configure bower directory for development
├── .editorconfig # Editor configuration for code consistency
├── .gitignore # Includes files that Git should ignore
├── .jshintrc # JSHint config with angular global support
├── LICENSE # Custom license file with your name in it
├── README.md # Basic README.md with title of your library
├── bower.json # Bower configuration with custom devDependencies and ignore files
├── dist # This folder and contents is generated by running gulp
│ ├── sample-library.js # Your library, ready to use in your development environment
│ └── sample-library.min.js # Your library, ready to use in your production environment
├── gulpfile.js # Gulp configuration with definition to build your library
├── karma-dist-concatenated.conf.js # Karma configuration to run unit tests using sample-library.js
├── karma-dist-minified.conf.js # Karma configuration to run unit tests using sample-library.min.js
├── karma-src.conf.js # Karma configuration to run unit tests using src/**/*.js
├── package.json # Npm configuration with necessary dependencies for development
├── src # Source directory
│ └── sample-library
│ ├── directives # Directory where you can store directives
│ ├── filters # Directory where you can store filters
│ ├── sampleLibrary.module.js # Main module file
│ └── services # Directory where you can store services
└── test
├── e2e
│ └── sample-library # Directory where you can store E2E tests
└── unit
└── sample-library
├── directives # Directory where you can store unit tests for directives
├── filters # Directory where you can store unit tests for filters
├── sampleLibrarySpec.js # Unit tests for main module
└── services # Directory where you can store unit tests for services How to use the generated boilerplateThe basic library structure is automatically created for you in the You can edit the existing files or add additional files in the Once you have added files in the $ gulp First gulp will
to make sure the code is fine. Then all files in the
Manually testing your codeThe generator creates 3 configurations for unit testing:
By default, # Run unit tests using src/**/*.js
$ gulp test-src
# Run unit tests using dist/<your-library-name>.js
$ gulp test-dist-concatenated
# Run unit tests using dist/<your-library-name>.min.js
$ gulp test-dist-minified This allows you to unit test the different builds of your code to ensure they all work as expected. How to write a testSuppose you have a service: // src/my-lib/services/some-service.js
angular.module('myLib.services')
.service('someService', function() {
this.foo = function() {
return 1234;
};
}); Then you write a test like this: describe('someService', function() {
var someService;
// load the module
beforeEach(module('myLib.services'));
// inject the service
beforeEach(inject(function(_someService_) {
someService = _someService_;
}));
it('should exist', function() {
expect(someService).to.be.ok;
});
it('should have a method called foo', function() {
expect(someService.foo).to.be.a('function');
});
}); Want to contribute?Help make this project better - fork and send a PR or create an issue. Change logv3.3.1
v3.3.0
v3.2.0
v3.1.0
v3.0.0
v2.0.0
v1.4.0
v1.3.0
v1.2.1
v1.2.0
v1.1.0
v1.0.3
LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论