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

Implemented new command #3

Merged
merged 9 commits into from
Aug 14, 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
5 changes: 5 additions & 0 deletions .changeset/witty-chefs-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"blueprints-addon": minor
---

Implemented new command
2 changes: 2 additions & 0 deletions packages/blueprints-addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"test": "./build.sh --test && mt dist-for-testing --quiet"
},
"dependencies": {
"@codemod-utils/ast-javascript": "^1.2.8",
"@codemod-utils/blueprints": "^1.1.5",
"@codemod-utils/json": "^1.1.9",
"@codemod-utils/files": "^2.0.4",
"yargs": "^17.7.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# unconventional js
/blueprints/*/files/

# compiled output
/declarations/
/dist/

# misc
/coverage/
!.*
.*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

require('@shared-configs/eslint-config-ember/patch');

module.exports = {
extends: ['@shared-configs/eslint-config-ember/v2-addon'],
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
},
overrides: [
// TypeScript files
{
files: ['**/*.{gts,ts}'],
rules: {
'@typescript-eslint/no-unnecessary-condition': 'error',
},
},
// JavaScript files
{
files: ['**/*.{cjs,js,gjs,mjs}'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# unconventional js
/blueprints/*/files/

# compiled output
/declarations/
/dist/
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('@shared-configs/prettier');
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# unconventional files
/blueprints/*/files/

# compiled output
/declarations/
/dist/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: ['@shared-configs/stylelint'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('@shared-configs/ember-template-lint');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# <%= options.addon.name %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# <%= options.addon.name %>

## Local development

```sh
# Lint files
pnpm lint
pnpm lint:fix

# Build addon
pnpm build
```

## Compatibility

* Node.js v18 or above
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# compiled output
/declarations/
/dist/

# dependencies
/node_modules/

# misc
/.eslintcache
/.stylelintcache

# npm/pnpm/yarn pack output
*.tgz
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const { addonV1Shim } = require('@embroider/addon-shim');

module.exports = addonV1Shim(__dirname);
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"plugins": [
[
"@babel/plugin-transform-typescript",
{
"allExtensions": true,
"allowDeclareFields": true,
"onlyRemoveTypeImports": true
}
],
"@embroider/addon-dev/template-colocation-plugin",
[
"babel-plugin-ember-template-compilation",
{
"targetFormat": "hbs",
"transforms": []
}
],
[
"module:decorator-transforms",
{
"runtime": {
"import": "decorator-transforms/runtime"
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"name": "<%= options.addon.name %>",
"version": "0.0.0",
"private": true,
"description": "",
"keywords": [
"ember-addon"
],
"repository": "",
"exports": {
".": {
"types": "./declarations/index.d.ts",
"default": "./dist/index.js"
},
"./*": {
"types": "./declarations/*.d.ts",
"default": "./dist/*.js"
},
"./addon-main.js": "./addon-main.cjs"
},
"typesVersions": {
"*": {
"*": [
"declarations/*"
]
}
},
"directories": {
"doc": "doc",
"test": "tests"
},
"files": [
"addon-main.cjs",
"declarations",
"dist",
"public"
],
"scripts": {
"build": "concurrently 'pnpm:build:*' --names 'build:'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'",
"lint:css": "stylelint '**/*.css' --allow-empty-input --cache",
"lint:css:fix": "stylelint '**/*.css' --allow-empty-input --fix",
"lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"prelint:types": "type-css-modules --src src",
"lint:types": "glint",
"prepack": "rollup --config",
"start": "concurrently 'pnpm:start:*' --names 'start:'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"test": "echo 'A v2 addon does not have tests, run tests in <%= options.testApp.location %>'"
},
"dependencies": {
"@embroider/addon-shim": "^1.8.9",
"decorator-transforms": "^2.0.0",
"embroider-css-modules": "^2.0.10"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-transform-typescript": "^7.25.2",
"@babel/runtime": "^7.25.0",
"@embroider/addon-dev": "^5.0.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^1.4.0",
"@glint/environment-ember-loose": "^1.4.0",
"@glint/environment-ember-template-imports": "^1.4.0",
"@glint/template": "^1.4.0",
"@rollup/plugin-babel": "^6.0.4",
"@shared-configs/ember-template-lint": "workspace:*",
"@shared-configs/eslint-config-ember": "workspace:*",
"@shared-configs/prettier": "workspace:*",
"@shared-configs/stylelint": "workspace:*",
"@shared-configs/typescript": "workspace:*",
"babel-plugin-ember-template-compilation": "^2.2.5",
"concurrently": "^8.2.2",
"ember-source": "~5.10.2",
"ember-template-lint": "^6.0.0",
"eslint": "^8.57.0",
"postcss": "^8.4.41",
"prettier": "^3.3.3",
"rollup": "^4.20.0",
"rollup-plugin-postcss": "^4.0.2",
"stylelint": "^16.8.1",
"type-css-modules": "^1.0.12",
"typescript": "^5.5.4"
},
"engines": {
"node": "18.* || >= 20"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"ember": {
"edition": "octane"
},
"ember-addon": {
"app-js": {},
"main": "addon-main.cjs",
"public-assets": {},
"type": "addon",
"version": 2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { Addon } from '@embroider/addon-dev/rollup';
import { babel } from '@rollup/plugin-babel';
import postcss from 'rollup-plugin-postcss';

const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});

export default {
// This provides defaults that work well alongside `publicEntrypoints` below.
// You can augment this if you need to.
output: addon.output(),

plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
// By default all your JavaScript modules (**/*.js) will be importable.
// But you are encouraged to tweak this to only cover the modules that make
// up your addon's public API. Also make sure your package.json#exports
// is aligned to the config here.
// See https://github.com/embroider-build/embroider/blob/main/docs/v2-faq.md#how-can-i-define-the-public-exports-of-my-addon
addon.publicEntrypoints([
'**/*.js',
'index.js',
'template-registry.js',
'test-support.js',
]),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
// not everything in publicEntrypoints necessarily needs to go here.
addon.appReexports([
'components/**/*.js',
'helpers/**/*.js',
'modifiers/**/*.js',
'services/**/*.js',
'utils/**/*.js',
]),

// Follow the V2 Addon rules about dependencies. Your code can import from
// `dependencies` and `peerDependencies` as well as standard Ember-provided
// package names.
addon.dependencies(),

// Implement CSS modules
postcss({
autoModules: false,
modules: {
generateScopedName: '<%= options.addon.dasherizedName %>__[sha512:hash:base64:5]',
},
}),

// This babel config should *not* apply presets or compile away ES modules.
// It exists only to provide development niceties for you, like automatic
// template colocation.
//
// By default, this will load the actual babel config from the file
// babel.config.json.
babel({
babelHelpers: 'bundled',
extensions: ['.gjs', '.gts', '.js', '.ts'],
}),

// Ensure that standalone .hbs files are properly integrated as Javascript.
addon.hbs(),

// Ensure that .gjs files are properly integrated as Javascript
addon.gjs(),

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
addon.keepAssets([]),

// Update public-assets field in package.json
addon.publicAssets('public/assets', {
exclude: ['**/.gitkeep'],
namespace: '<%= options.addon.name %>',
}),

// Remove leftover build artifacts when starting a new build.
addon.clean(),
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default interface <%= options.addon.pascalCaseName %>Registry {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@shared-configs/typescript/ember",
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowJs": true,
"declarationDir": "declarations",
"rootDir": "./src",
"skipLibCheck": true
},
"include": [
"src/**/*",
"unpublished-development-types/**/*"
],
"glint": {
"environment": [
"ember-loose",
"ember-template-imports"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Add any types here that you need for local development only.
// These will *not* be published as part of your addon, so be careful that your published code does not rely on them!

import '@glint/environment-ember-loose';
import '@glint/environment-ember-template-imports';
import 'ember-source/types';

import type EmbroiderCssModulesRegistry from 'embroider-css-modules/template-registry';

import type <%= options.addon.pascalCaseName %>Registry from '../src/template-registry.ts';

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry
extends <%= options.addon.pascalCaseName %>Registry,
EmbroiderCssModulesRegistry {
// Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
// See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons
}
}
Loading