From 9621fe759af357332fd0a6170ce7ca114bdef0b5 Mon Sep 17 00:00:00 2001 From: Mark David Avery Date: Mon, 4 Apr 2022 02:45:18 -0700 Subject: [PATCH] feat(classic structure): first pass on adding classic component structure --- packages/colocation/lib/base.js | 11 ++++++++++- .../generate-default-style-namespace-manifest.js | 3 ++- packages/namespace/lib/component-names.js | 5 ++++- .../tests/acceptance/classic-structure-test.js | 2 +- .../app/templates/components/classic-structure.hbs | 4 +++- .../components/nested/classic-structure-nested.hbs | 4 +++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/colocation/lib/base.js b/packages/colocation/lib/base.js index ba69be5..9301eaf 100644 --- a/packages/colocation/lib/base.js +++ b/packages/colocation/lib/base.js @@ -1,4 +1,7 @@ +const path = require('path'); + const funnel = require('broccoli-funnel'); +const merge = require('broccoli-merge-trees'); module.exports = class Base { constructor(options) { @@ -18,7 +21,13 @@ module.exports = class Base { annotation: 'Funnel (ember-cli-styles-colocation grab files addon style files)', }); - return funnel(baseFiles, { + const classicStyles = funnel(tree, { + srcDir: path.join(srcDir, 'styles', 'component-styles'), + destDir, + allowEmpty: true, + }); + + return funnel(merge([baseFiles, classicStyles], { overwrite: true }), { include: [`**/*.{${this.extentions},}`], exclude: [`**/styles/**/*`], allowEmpty: true, diff --git a/packages/namespace/addon/utils/generate-default-style-namespace-manifest.js b/packages/namespace/addon/utils/generate-default-style-namespace-manifest.js index 53fa54d..ed098a3 100644 --- a/packages/namespace/addon/utils/generate-default-style-namespace-manifest.js +++ b/packages/namespace/addon/utils/generate-default-style-namespace-manifest.js @@ -4,7 +4,8 @@ function formatFullName(stylePath) { return stylePath .replace(/(\/(styles?|index))?\.(css|less|scss|sass|styl)$/, '') .replace(/.*?\//, '') - .replace(/^components\//, ''); + .replace(/^components\//, '') + .replace(/^templates\//, ''); } export function generateDefaultStyleNamespaceManifest(owner, styleExtensions) { diff --git a/packages/namespace/lib/component-names.js b/packages/namespace/lib/component-names.js index dfb0807..a8d8d9e 100644 --- a/packages/namespace/lib/component-names.js +++ b/packages/namespace/lib/component-names.js @@ -5,7 +5,10 @@ module.exports = { path(actualPath) { const { dir, name } = path.parse(actualPath); - return path.join(dir, name.replace(/(template|component|styles?|index)$/, '')); + return path.join( + dir.replace(/(templates|components)/g, ''), + name.replace(/(template|component|styles?|index)$/g, '') + ); }, class(actualPath, terseClassNames) { diff --git a/packages/namespace/tests/acceptance/classic-structure-test.js b/packages/namespace/tests/acceptance/classic-structure-test.js index cfe6c48..44ef0fe 100644 --- a/packages/namespace/tests/acceptance/classic-structure-test.js +++ b/packages/namespace/tests/acceptance/classic-structure-test.js @@ -4,7 +4,7 @@ import { setupApplicationTest } from 'ember-qunit'; import styleForSetup from 'dummy/tests/setup/style-for'; -module.skip('Acceptance | classic structure', function (hooks) { +module('Acceptance | classic structure', function (hooks) { setupApplicationTest(hooks); styleForSetup(hooks); diff --git a/packages/namespace/tests/dummy/app/templates/components/classic-structure.hbs b/packages/namespace/tests/dummy/app/templates/components/classic-structure.hbs index c10c903..9416901 100644 --- a/packages/namespace/tests/dummy/app/templates/components/classic-structure.hbs +++ b/packages/namespace/tests/dummy/app/templates/components/classic-structure.hbs @@ -1 +1,3 @@ - \ No newline at end of file +
+ +
\ No newline at end of file diff --git a/packages/namespace/tests/dummy/app/templates/components/nested/classic-structure-nested.hbs b/packages/namespace/tests/dummy/app/templates/components/nested/classic-structure-nested.hbs index 5b63f5f..91b05e2 100644 --- a/packages/namespace/tests/dummy/app/templates/components/nested/classic-structure-nested.hbs +++ b/packages/namespace/tests/dummy/app/templates/components/nested/classic-structure-nested.hbs @@ -1 +1,3 @@ - \ No newline at end of file +
+ +
\ No newline at end of file