Skip to content

Commit 55f7512

Browse files
authored
Revert "feat(ember-cli): Ember cli classic (#185)."
This reverts commit 85d9707.
1 parent 85d9707 commit 55f7512

File tree

129 files changed

+2743
-2607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+2743
-2607
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ language: node_js
66

77
node_js:
88
- "8"
9-
- "10"
9+
- "9"
1010

1111
env:
1212
- CXX=g++-4.8

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"chai": "^3.5.0",
2828
"husky": "^0.14.3",
2929
"istanbul": "^0.4.5",
30-
"lerna": "^2.11.0",
30+
"lerna": "^3.0.0-beta.1",
3131
"loader-utils": "^1.1.0",
3232
"markdown-toc": "^1.2.0",
3333
"mocha": "^3.4.2",
@@ -36,6 +36,7 @@
3636
"mock-require": "^2.0.2",
3737
"outdent": "^0.4.1",
3838
"perfectionist": "^2.4.0",
39+
"postcss": "^6.0.21",
3940
"prettier": "^1.8.2",
4041
"remap-istanbul": "^0.9.5",
4142
"source-map-support": "^0.4.15",
@@ -44,7 +45,7 @@
4445
"tslint": "^5.9.1",
4546
"typedoc": "^0.11.0",
4647
"typedoc-plugin-monorepo": "^0.1.0",
47-
"typescript": "~2.8.0",
48+
"typescript": "^2.8.1",
4849
"watch": "^1.0.2"
4950
},
5051
"workspaces": [

packages/@css-blocks/broccoli/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"debug": "^3.1.0",
4646
"fs-extra": "^5.0.0",
4747
"opticss": "^0.3.0",
48+
"postcss": "^6.0.21",
4849
"recursive-readdir": "^2.2.2",
4950
"walk-sync": "^0.3.2"
5051
}

packages/@css-blocks/broccoli/src/index.ts

+26-47
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,73 @@
11
import * as fs from "fs-extra";
22
import * as path from "path";
33

4-
import { Analyzer, Block, BlockCompiler, StyleMapping } from "@css-blocks/core";
4+
import { Analyzer, BlockCompiler, StyleMapping } from "@css-blocks/core";
55
import { TemplateTypes } from "@opticss/template-api";
6-
76
import * as debugGenerator from "debug";
8-
import { OptiCSSOptions, Optimizer, postcss } from "opticss";
7+
import { OptiCSSOptions, Optimizer } from "opticss";
8+
import * as postcss from "postcss";
99
import * as readdir from "recursive-readdir";
1010

1111
import { BroccoliPlugin } from "./utils";
1212

1313
const debug = debugGenerator("css-blocks:broccoli");
1414

15-
export interface Transport {
16-
id: string;
17-
mapping?: StyleMapping<keyof TemplateTypes>;
18-
blocks?: Set<Block>;
19-
analyzer?: Analyzer<keyof TemplateTypes>;
20-
css?: string;
21-
}
22-
2315
export interface BroccoliOptions {
2416
entry: string[];
2517
output: string;
26-
root: string;
2718
analyzer: Analyzer<keyof TemplateTypes>;
28-
transport: Transport;
19+
transport: {[key: string]: object};
2920
optimization?: Partial<OptiCSSOptions>;
3021
}
3122

3223
class BroccoliCSSBlocks extends BroccoliPlugin {
3324

3425
private analyzer: Analyzer<keyof TemplateTypes>;
35-
private entries: string[];
26+
private entry: string[];
3627
private output: string;
37-
private root: string;
38-
private transport: Transport;
28+
private transport: { [key: string]: object };
3929
private optimizationOptions: Partial<OptiCSSOptions>;
30+
4031
// tslint:disable-next-line:prefer-whatever-to-any
4132
constructor(inputNode: any, options: BroccoliOptions) {
4233
super([inputNode], { name: "broccoli-css-blocks" });
4334

44-
this.entries = options.entry.slice(0);
45-
this.output = options.output || "css-blocks.css";
35+
this.entry = options.entry;
36+
this.output = options.output;
37+
this.analyzer = options.analyzer;
4638
this.transport = options.transport;
4739
this.optimizationOptions = options.optimization || {};
48-
this.analyzer = options.analyzer;
49-
this.root = options.root || process.cwd();
50-
this.transport.css = this.transport.css ? this.transport.css : "";
40+
41+
if (!this.output) {
42+
throw new Error("CSS Blocks Broccoli Plugin requires an output file name.");
43+
}
5144
}
5245

5346
async build() {
5447
let options = this.analyzer.cssBlocksOptions;
5548
let blockCompiler = new BlockCompiler(postcss, options);
5649
let optimizer = new Optimizer(this.optimizationOptions, this.analyzer.optimizationOptions);
5750

58-
// When no entry points are passed, we treat *every* template as an entry point.
59-
let discover = !this.entries.length;
60-
6151
// This build step is *mostly* just a pass-through of all files!
6252
// QUESTION: Tom, is there a better way to do this in Broccoli?
6353
let files = await readdir(this.inputPaths[0]);
6454
for (let file of files) {
6555
file = path.relative(this.inputPaths[0], file);
66-
67-
// If we're in Classic or Pods mode, every hbs file is an entry point.
68-
if (discover && path.extname(file) === ".hbs") { this.entries.push(file); }
69-
70-
fs.ensureDirSync(path.join(this.outputPath, path.dirname(file)));
56+
await fs.ensureDir(path.join(this.outputPath, path.dirname(file)));
7157
try {
72-
fs.symlinkSync(
58+
await fs.symlink(
7359
path.join(this.inputPaths[0], file),
7460
path.join(this.outputPath, file),
7561
);
7662
} catch (e) {
7763
// tslint:disable-next-line:no-console
7864
console.log("Error linking", path.join(this.inputPaths[0], file), "to output directory.");
7965
}
80-
8166
}
8267

83-
// The glimmer-analyzer package tries to require() package.json
84-
// in the root of the directory it is passed. We pass it our broccoli
85-
// tree, so it needs to contain package.json too.
86-
// TODO: Ideally this is configurable in glimmer-analyzer. We can
87-
// contribute that option back to the project. However,
88-
// other template integrations may want this available too...
89-
fs.writeFileSync(
90-
path.join(this.outputPath, "package.json"),
91-
fs.readFileSync(path.join(this.root, "package.json")),
92-
);
93-
9468
// Oh hey look, we're analyzing.
9569
this.analyzer.reset();
96-
await this.analyzer.analyze(this.outputPath, this.entries);
70+
await this.analyzer.analyze(...this.entry);
9771

9872
// Compile all Blocks and add them as sources to the Optimizer.
9973
// TODO: handle a sourcemap from compiling the block file via a preprocessor.
@@ -106,9 +80,10 @@ class BroccoliCSSBlocks extends BroccoliPlugin {
10680
let filename = filesystemPath || options.importer.debugIdentifier(block.identifier, options);
10781

10882
// If this Block has a representation on disk, remove it from our output tree.
83+
// TODO: This isn't working right now because `importer.filesystemPath` doesn't return the expected path...
10984
if (filesystemPath) {
110-
debug(`Removing block file ${filesystemPath} from output.`);
111-
fs.unlinkSync(filesystemPath);
85+
debug(`Removing block file ${path.relative(options.rootDir, filesystemPath)} from output.`);
86+
await fs.unlink(path.join(this.outputPath, path.relative(options.rootDir, filesystemPath)));
11287
}
11388

11489
// Add the compiled Block file to the optimizer.
@@ -131,9 +106,13 @@ class BroccoliCSSBlocks extends BroccoliPlugin {
131106
this.transport.mapping = styleMapping;
132107
this.transport.blocks = blocks;
133108
this.transport.analyzer = this.analyzer;
134-
this.transport.css += optimized.output.content.toString();
109+
this.transport.css = optimized.output;
135110

136-
debug(`Compilation Finished: ${this.transport.id}`);
111+
// Write our compiled CSS to the output tree.
112+
await fs.writeFile(
113+
path.join(this.outputPath, this.output),
114+
optimized.output.content.toString(),
115+
);
137116

138117
}
139118

packages/@css-blocks/broccoli/test/plugin-test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as assert from "assert";
2-
import * as path from "path";
2+
import * as fs from "fs-extra";
3+
// import * as path from "path";
34

45
import { GlimmerAnalyzer } from "@css-blocks/glimmer";
56
import { TempDir, buildOutput, createTempDir } from "broccoli-test-helper";
@@ -49,8 +50,8 @@ describe("Broccoli Plugin Test", function () {
4950
},
5051
});
5152

52-
let transport = { id: "test-transport" };
53-
let analyzer = new GlimmerAnalyzer({}, {}, {
53+
let transport = {};
54+
let analyzer = new GlimmerAnalyzer(input.path(), {
5455
app: { name: "test" },
5556
types: {
5657
stylesheet: { definitiveCollection: "components" },
@@ -63,18 +64,18 @@ describe("Broccoli Plugin Test", function () {
6364

6465
let compiler = new BroccoliCSSBlocks(input.path(), {
6566
entry: [entryComponentName],
66-
root: path.join(__dirname, "../.."),
6767
output: "css-blocks.css",
6868
transport,
6969
analyzer,
7070
});
71-
await buildOutput(compiler);
71+
let output = await buildOutput(compiler);
7272

7373
assert.ok(Object.keys(transport).length, "Transport Object populated");
7474
assert.ok(transport["mapping"], "Mapping property is populated in Transport Object");
7575
assert.ok(transport["blocks"], "Blocks property is populated in Transport Object");
7676
assert.ok(transport["analyzer"], "Analyzer property is populated in Transport Object");
7777
assert.ok(transport["css"], "CSS property is populated in Transport Object");
78+
assert.equal(await fs.readFile(output.path("css-blocks.css"), "utf8"), transport["css"].content, "CSS File generated");
7879
});
7980
});
8081
});

packages/@css-blocks/core/src/Analyzer/Analyzer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export abstract class Analyzer<K extends keyof TemplateTypes> {
5050
this.dynamicStyles = new MultiMap();
5151
}
5252

53-
abstract analyze(dir: string, entryPoints: string[]): Promise<Analyzer<K>>;
53+
abstract analyze(...entryPoints: string[]): Promise<Analyzer<K>>;
5454
abstract get optimizationOptions(): TemplateIntegrationOptions;
5555

5656
// TODO: We don't really want to burn the world here.

packages/@css-blocks/core/src/BlockCompiler/ConflictResolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export class ConflictResolver {
422422
}
423423

424424
// Wrap our list of CompoundSelectors in ParsedSelector containers and return.
425-
return mergedSelectors.map(sel => new ParsedSelector(sel, sel.toString()));
425+
return mergedSelectors.map(sel => new ParsedSelector(sel));
426426
}
427427
sourceLocation(block: Block, node: postcss.Node): SourceLocation | undefined {
428428
let blockPath = this.config.importer.debugIdentifier(block.identifier, this.config);

packages/@css-blocks/core/src/BlockTree/AttrValue.ts

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ export class AttrValue extends Style<AttrValue, Block, Attribute, never> {
8989
switch (config.outputMode) {
9090
case OutputMode.BEM:
9191
return `${this.parent.cssClass(config)}${ this.isPresenceRule ? "" : `-${this.value}`}`;
92-
case OutputMode.BEM_UNIQUE:
93-
return `${this.parent.cssClass(config)}${ this.isPresenceRule ? "" : `-${this.value}`}`;
9492
default:
9593
return assertNever(config.outputMode);
9694
}

packages/@css-blocks/core/src/BlockTree/Attribute.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ export class Attribute extends Inheritable<Attribute, Block, BlockClass, AttrVal
169169
cssClass(config: ResolvedConfiguration) {
170170
switch (config.outputMode) {
171171
case OutputMode.BEM:
172-
return `${this.blockClass.cssClass(config)}--${this.token.name}`;
173-
case OutputMode.BEM_UNIQUE:
174-
return `${this.blockClass.cssClass(config)}--${this.token.name}`;
172+
let cssClassName = this.blockClass.cssClass(config);
173+
return `${cssClassName}--${this.token.name}`;
175174
default:
176175
return assertNever(config.outputMode);
177176
}

packages/@css-blocks/core/src/BlockTree/Block.ts

-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as crypto from "crypto";
2-
31
import { MultiMap, ObjectDictionary } from "@opticss/util";
42
import { whatever } from "@opticss/util";
53
import {
@@ -22,24 +20,6 @@ import { BlockClass } from "./BlockClass";
2220
import { Inheritable } from "./Inheritable";
2321
import { Styles } from "./Styles";
2422

25-
// Random seed for `get_guid`. Consistent for life of process.
26-
const RAND_SEED = Math.floor(Math.random() * 1000);
27-
28-
/**
29-
* Generates a 5 digit, process-wide globally unique
30-
* identifier from a given input identifier. This
31-
* generated identifier hash will remain consistent
32-
* for the life of the process that spawned it.
33-
* @prop identifier string Input Block identifier.
34-
* @returns This Block's guid hash.
35-
*/
36-
function gen_guid(identifier: string): string {
37-
return crypto.createHash("md5")
38-
.update(identifier + RAND_SEED)
39-
.digest("hex")
40-
.slice(0, 5);
41-
}
42-
4323
export class Block
4424
extends Inheritable<Block, Block, never, BlockClass> {
4525

@@ -49,8 +29,6 @@ export class Block
4929
private _implements: Block[] = [];
5030
private hasHadNameReset = false;
5131

52-
public readonly guid: string;
53-
5432
/**
5533
* array of paths that this block depends on and, if changed, would
5634
* invalidate the compiled css of this block. This is usually only useful in
@@ -67,7 +45,6 @@ export class Block
6745
this._dependencies = new Set<string>();
6846
this.rootClass = new BlockClass(ROOT_CLASS, this);
6947
this.stylesheet = stylesheet;
70-
this.guid = gen_guid(identifier);
7148
this.addClass(this.rootClass);
7249
}
7350

packages/@css-blocks/core/src/BlockTree/BlockClass.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ export class BlockClass extends Style<BlockClass, Block, Block, Attribute> {
198198
public cssClass(config: ResolvedConfiguration): string {
199199
switch (config.outputMode) {
200200
case OutputMode.BEM:
201-
return this.isRoot ? `${this.block.name}` : `${this.block.name}__${this.name}`;
202-
case OutputMode.BEM_UNIQUE:
203-
return this.isRoot ? `${this.block.name}_${this.block.guid}` : `${this.block.name}_${this.block.guid}__${this.name}`;
201+
if (this.isRoot) {
202+
return `${this.block.name}`;
203+
} else {
204+
return `${this.block.name}__${this.name}`;
205+
}
204206
default:
205207
return assertNever(config.outputMode);
206208
}

packages/@css-blocks/core/src/configuration/OutputMode.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
*/
44
export enum OutputMode {
55
BEM = "BEM",
6-
BEM_UNIQUE = "BEM_UNIQUE",
76
}

0 commit comments

Comments
 (0)